可以将依赖于System.Net.Http.WinHttpHandler的库部署到Linux

时间:2017-02-26 18:38:09

标签: linux cross-platform .net-core nuget-package .net-standard

我正在考虑使用支持NETSTANDARD1.3的Consul library for .NET。当我添加包时,我看到它依赖于System.Net.Http.WinHttpHandler,它依次添加了win32原语包。

我找不到任何文档来说明这些软件包在Linux上是如何工作的。我认为它们不起作用,但它们有可能提供垫片层。

有没有人对这些套餐有过经验?

编辑:

作为自包含部署部署到Ubuntu会产生以下结果。

Unhandled Exception: System.TypeInitializationException: The type initializer for 'System.Net.Http.CurlHandler' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Http' threw an exception. ---> System.TypeInitializationException: The type initializer for 'HttpInitializer' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'System.Net.Http.Native': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at Interop.HttpInitializer.EnsureCurlIsInitialized() at Interop.HttpInitializer..cctor() --- End of inner exception stack trace --- at Interop.HttpInitializer.Initialize() at Interop.Http..cctor() --- End of inner exception stack trace --- at Interop.Http.GetSupportedFeatures() at System.Net.Http.CurlHandler..cctor() --- End of inner exception stack trace --- at System.Net.Http.CurlHandler..ctor() at Consul.ConsulClient.ConsulClientConfigurationContainer..ctor() at Consul.ConsulClient..ctor(Action`1 configOverride, Action`1 clientOverride, Action`1 handlerOverride) at REstateScratchPad.Program.Main(String[] args) Aborted (core dumped)

2 个答案:

答案 0 :(得分:1)

我认为你不需要安装SDK,因为我能够使用它。您使用的是哪个版本的Ubuntu?您是否按照https://docs.microsoft.com/en-us/dotnet/articles/core/deploying/(详见下文)中详述的步骤进行操作?

我说这是因为我构建了一个测试应用程序,在没有安装SDK的情况下工作正常:

  1. 按照上述指南修改project.json,然后移除"platform": true。添加runtimes: {}元素,对我来说是: "runtimes": { "win81-x64": {}, "ubuntu.14.04-x64": {} }

  2. 在我这样做之后,我能够执行dotnet restoredotnet build -r ubuntu.14.04-x64工作,但只删除了目录中的3个文件,并且在没有SDK的情况下无法运行。

  3. 我做了dotnet publish -c release -r ubuntu.14.04-x64并启动了一个运行Ubuntu 14.04,apt-get install libunwind8的Vagrant框,然后运行我的程序:/vagrant/bin/release/netcoreapp1.0/ubuntu.14.04-x64/publish/ConsoleApp1。所有程序都是位于Consul.NET project的README.md中的示例函数,并且在我在VM中启动Consul副本后能够正确打印“Hello Consul”。

答案 1 :(得分:0)

事实上,Linux确实支持这种依赖,因为它是.NETStandard的一部分,并为CURL处理程序提供了垫片。

部署应用程序确实导致错误,如原始帖子中所示,但安装SDK解决了这些错误。

旁注:我认为我不需要SDK来运行自包含部署。

相关问题