Xamarin在HttpClient中形成Android错误ENOBUFS

时间:2018-06-19 22:53:16

标签: android exception xamarin.forms buffer httpclient

我现在正在经历同样的问题。我在iOS和Android上有一个项目。在iOS中的REST调用中可以完美运行,但是当我运行Android项目时,会发生以下错误:

错误:

http://floating-point-gui.de/errors/comparison/

下面,微软建议的设置:

enter image description here

遵循以下代码:

var client = new HttpClient(new NativeMessageHandler());    

client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, ApiUrlBase + string.Format(ApiUrl, method, param));

HttpResponseMessage response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);  

if (response.IsSuccessStatusCode)
{
   string resultContent = await response.Content.ReadAsStringAsync();
   rootobject = JsonConvert.DeserializeObject<T>(resultContent);
}

0 个答案:

没有答案