According to the List of .NET CoreFx APIs and their associated .NET Platform Standard version, System.Runtime.Serialization.Formatters is added into to the .NET Platform Standard since 1.3, which is cool, but when I try to create a .Net Core class library targeting netstandard1.5 under.Net Core RC2, I can't use it.
The code is simple, just intending to declare a BinaryFormatter:
public class Problems {
private System.Runtime.Serialization.Formatters.Binary.BinaryFormatter _formatter;
}
Error is :
Error CS0234 The type or namespace name 'Serialization' does not exist in the namespace 'System.Runtime' (are you missing an assembly reference?)
Here is the project.json, which I did no modifications:
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027",
},
"frameworks": {
"netstandard1.5": {
"imports": "dnxcore50"
}
}
}
So, is there another package that I need depend on? And Why? Shouldn't a netstandard moniker be enough for all the APIs in the list?
- The
System.Runtime.Serialization.Formatters
package was added after RC2, it should be included in the 1.0 release tomorrow. In the meantime, you can use a version from MyGet. - The 1.0 version of
System.Runtime.Serialization.Formatters
will not containBinaryFormatter
. It mostly contains serialization attributes and interfaces, and types used by them. The full API of that package is here. - Even then,
System.Runtime.Serialization.Formatters
is not referenced byNETStandard.Library
. If you want to use it, you will need to explicitly add it to your project.json. BinaryFormatter
will be available in a future version of .Net Core.
You cannot find BinaryFormatter
in RC2,
http://packagesearch.azurewebsites.net/
About whether it would be part of .NET Core, you can refer to this pull request,
https://github.com/dotnet/corefx/pull/8302/files
I guess it would be part of .NET Core 1.0 RTM, or 1.1 release.
来源:https://stackoverflow.com/questions/38036864/binaryformatter-in-netstandard-1-5