Netstandard 1.5中的BinaryFormatter [英] BinaryFormatter in netstandard 1.5

查看:75
本文介绍了Netstandard 1.5中的BinaryFormatter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 .NET CoreFx的列表从1.3开始,API及其相关的.NET Platform Standard版本,System.Runtime.Serialization.Formatters已添加到.NET Platform Standard中,这很酷,但是当我尝试创建面向.NET Core类库时.net Core RC2下的netstandard1.5,我不能使用它。

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.

代码很简单,只想声明一个BinaryFormatter:

The code is simple, just intending to declare a BinaryFormatter:

public class Problems {
    private System.Runtime.Serialization.Formatters.Binary.BinaryFormatter _formatter;
}

错误是:

错误CS0234在名称空间'System.Runtime'中,类型或名称空间名称'Serialization'不存在
(您是否缺少程序集
引用?)

Error CS0234 The type or namespace name 'Serialization' does not exist in the namespace 'System.Runtime' (are you missing an assembly reference?)

这是project.json,我没有做任何修改:

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?

推荐答案


  • code> System.Runtime.Serialization.Formatters 程序包是在RC2之后添加的,明天应该包含在1.0版本中。同时,您可以使用 MyGet 中的版本。

  • System.Runtime.Serialization.Formatters 的1.0版本将不包含 BinaryFormatter 。它主要包含序列化属性和接口以及它们使用的类型。 该程序包的完整API在这里。

  • 即使如此, System.Runtime.Serialization.Formatters NETStandard.Library 未引用。如果要使用它,则需要将其显式添加到project.json。

  • BinaryFormatter 将在将来的版本中提供.Net Core。

    • 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 contain BinaryFormatter. 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 by NETStandard.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.
    • 这篇关于Netstandard 1.5中的BinaryFormatter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆