小编Cat*_*tia的帖子

创建新的HttpClient时无法加载DLL'System.Security.Cryptography.Native.OpenSsl'

我正在使用.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: …
Run Code Online (Sandbox Code Playgroud)

c# macos openssl httpclient .net-core

8
推荐指数
1
解决办法
1530
查看次数

标签 统计

.net-core ×1

c# ×1

httpclient ×1

macos ×1

openssl ×1