VS 2017 .NET Core BinaryFormatter [英] VS 2017 .NET Core BinaryFormatter

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

问题描述

VS 2017 中发布的 .NET Core 工具是否包含 BinaryFormatter?当我创建 .NET Core 控制台应用程序时,我找不到 BinaryFormatter.有很多 Nuget 包,但哪一个是使用 .NET Core 获得可工作的 BinaryFormatter 的正确包?

Is with VS 2017 released in the .NET Core tools BinaryFormatter included? When I create a .NET Core console application I cannot find BinaryFormatter. There are many Nuget packages but which one is the right one to get a working BinaryFormatter with .NET Core?

顺便说一句,使用已发布的 Visual Studio 创建一个无法编译的项目有点尴尬.我需要启动我的 .NET Core 控制台应用程序所在的 cmd shell 并执行

By the way it is a bit awkward to create with a released Visual Studio a project which does not compile. I need to start a cmd shell where my .NET Core console application resides and do a

dotnet restore

让它编译.我是否错过了参考菜单中的 VS 命令?

to get it to compile. Did I miss a VS command in the references menu?

编辑1

使用 Install-Package BinaryFormatter 给我一个例外

PM> Install-Package BinaryFormatter
Restoring packages for d:sourcevc17NetCoreAppConsoleApp1ConsoleApp2ConsoleApp2.csproj...
Install-Package : Package BinaryFormatter 1.0.2 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package BinaryFormatter 1.0.2 supports:
  - dnx451 (DNX,Version=v4.5.1)
  - dnxcore50 (DNXCore,Version=v5.0)
At line:1 char:1
+ Install-Package BinaryFormatter
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : One or more packages are incompatible with .NETCoreApp,Version=v1.1.
At line:1 char:1
+ Install-Package BinaryFormatter
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : Package restore failed. Rolling back package changes for 'ConsoleApp2'.
At line:1 char:1
+ Install-Package BinaryFormatter
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

推荐答案

EDIT

感谢@ClockEndGooner 指出,使用 .Net-Core 2.1 或更高版本的人有一个二进制格式化程序位于:

Thanks to @ClockEndGooner for pointing out, that People who are using .Net-Core 2.1 or later there is a Binary Formatter Located in:

System.Runtime.Serialization.Formatters.Binary

这里是一个nuget包,它说它也支持核心:

Here is a nuget package for that it says it supports core as well:

Install-Package BinaryFormatter

我不确定这是否包含您需要的但也是 System.Runtime.Serialization.Formatters

I'm not sure if this contains what you need but is also the System.Runtime.Serialization.Formatters

Install-Package System.Runtime.Serialization.Formatters

这些软件包适用于 .Net-Core 1.0 以便它们适用于 1.1 环境您需要交叉编译您可以参考此 核心问题

These packages work with .Net-Core 1.0 in order for them to work with a 1.1 enviroment you will require cross comiplation you can reference this Core Issue

这篇关于VS 2017 .NET Core BinaryFormatter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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