Cat*_*tia 8 c# macos openssl httpclient .net-core
我正在使用.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;
}
Run Code Online (Sandbox Code Playgroud)
我创建了指定运行时的发布包(在我的例子中是osx10.12-x64).在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.
Run Code Online (Sandbox Code Playgroud)
我的发布文件夹包含"System.Security.Cryptography.Native.OpenSsl.dylib"
这个链接(https://github.com/dotnet/cli/issues/5129)告诉我如何解决我的机器中的问题.
如何在没有dotnet的客户机器上执行此操作?
bar*_*njs 13
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).
有三个主要的解决方法.
您的客户从https://www.microsoft.com/net/core#macos遵循.NET Core for macOS先决条件:
Run Code Online (Sandbox Code Playgroud)$ 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/
如果您已完成独立构建,则可以使用libcrypto.1.0.0.dylib和libssl.1.0.0.dylib并将它们复制到应用程序目录中.
| 归档时间: |
|
| 查看次数: |
1530 次 |
| 最近记录: |