"HttpClientHandler:Dispose (bool)' is inaccessible from method `System.Net.ServicePointManager:CloseConnectionGroup (string)"
发送请求时出现这个错误,如何解决?
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(urlTemplate);
client.Timeout = new TimeSpan(0, 0, 30);
var connectionString = string.Format(UrlTemplate, method.ToString().ToLower(), CreateParametrsString(parametrs));
var response = await client.GetAsync(connectionString);
if (response.StatusCode != HttpStatusCode.OK)
{
using (StreamReader reader = new StreamReader((await response.Content.ReadAsStreamAsync()), Encoding.GetEncoding("windows-1252")))
{
content = reader.ReadToEnd();
var json = content;
var ass = JsonConvert.DeserializeObject<T>(json);
if (ass != null)
Debug.WriteLine(String.Format("=>GETTED [{0}] table.", typename));
else
LoggingService.Report(null, new Dictionary<string, string> {
{ "request",typename },
{ "content",content },
});
return ass;
}
}
}
最佳答案
您很可能遇到了 mono 框架中的错误。我相信是
https://bugzilla.xamarin.com/show_bug.cgi?id=41133
有两个拉取请求可以解决此问题:
https://github.com/mono/mono/pull/4277 (主修复)
https://github.com/mono/mono/pull/4278 (单声道 4.8 中的 Cycle9 修复)
包含此修复的当前 Mono 版本是:
https://github.com/mono/mono/releases/tag/mono-4.8.0.478
因此您需要一个包含此版本或更高版本的构建。
https://github.com/mono/mono/commits/084f91256b05249f5f35973019561e6fefbdc053/mono/utils/mono-sha1.c
因此这应该包含在当前的 Beta
channel 构建中:
https://releases.xamarin.com/beta-release-cycle-9-rc-refresh-builds3/
关于c# - HttpClientHandler :Dispose (bool )' is inaccessible from method ` System.Net.ServicePointManager:CloseConnectionGroup(字符串),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42018890/