我与.NET的核心工作,需要执行一个HTTP调用到我的服务器。 使用的代码如下:
try
{
var client = new HttpClient ();
var helloUri = new System.Uri (string.Concat ("http://localhost:1234", "/hello"));
var response = client.GetAsync (helloUri);
var helloReponse = response.Result;
return helloReponse.StatusCode == System.Net.HttpStatusCode.OK;
}
catch (System.Exception e)
{
throw e;
}
我创建的发布包与运行时指定的(在我的情况osx10.12-64)。在OSX工作时我有这样的错误:
(The type initializer for 'System.Net.Http.CurlHandler' threw an
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.TypeInitializationException: The type initializer for
'CryptoInitializer' threw an exception. --->
System.DllNotFoundException: Unable to load DLL
'System.Security.Cryptography.Native.OpenSsl': The specified module
could not be found.
我的发布文件夹中包含“System.Security.Cryptography.Native.OpenSsl.dylib”
此链接(https://github.com/dotnet/cli/issues/5129)告诉我怎么解决这个问题在我的机器。
我怎样才能做到这一点在客户机不具备的dotnet?
System.DllNotFoundException: Unable to load DLL 'System.Security.Cryptography.Native.OpenSsl': The specified module
could not be found.
几乎总是意味着 “我找不到OpenSSL的”(libcrypto.1.0.0.dylib / libssl.1.0.0.dylib)。
主要有三个解决方法。
$ brew update
$ brew install openssl
$ mkdir -p /usr/local/lib
$ ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
$ ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
为我工作的解决方案是第二个由@bartonjs建议。
我不得不修改我的libssl.dylib因为她引用libcrypto绝对路径。
otool -l libssl.1.0.0.dylib
showed the absolute path
install_name_tool -change usr/../Cellar/.. @rpath/libcrypto.1.0.0.dylib libssl.1.0.0.dylib
to change the path
是的,我使用网络核心2.2,而不是使用NET内核1.1.2解决了这个问题
您可以下载并安装由本
https://github.com/dotnet/core/blob/master/release-notes/2.2/2.2.1/2.2.1-download.md