System.NotImplementedException:ref类型的解释器

时间:2016-11-14 14:50:02

标签: c# ios xamarin xamarin.ios

我在xamarin.iOS中调用网络服务时遇到异常。

例外是:

  

System.NotImplementedException:ref类型的解释器。

相同的代码在Xamarin Android中运行良好。

我的代码如下。

string postData = String.Format("grant_type=password&username={0}&password={1}", userName, password);
byte[] bytes = Encoding.UTF8.GetBytes(postData);
string url = UrlConfig.LOGIN;
System.Diagnostics.Debug.Write(url);
var request = WebRequest.Create(url);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = bytes.Length;
request.Method = "POST";
request.Headers[UrlConfig.DATAPOWER_KEY] = UrlConfig.DATAPOWER_VALUE;

Stream dataStream = request.GetRequestStream();
dataStream.Write(bytes, 0, bytes.Length);
dataStream.Close();


using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
    if (response.StatusCode != HttpStatusCode.OK)
        Console.Out.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusCode);
    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
    {
        var content = reader.ReadToEnd();
   }

}

0 个答案:

没有答案