小编Ron*_*ira的帖子

System.Net.Http.Formatting库的PCL重新包装中的ReadAsAsync <>

尝试在System.Net.Http.Formatting的Bitrium.Http.Extensions重新包装中调用ReadAsAsync <>扩展方法时,我收到以下错误.

程序集'System.Net.Http.ObjectContent'中的方法'SerializeToStreamAsync'来自程序集'Bitrium.Http.Extensions,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 43390f7aed073600'没有实现.

我在PCL项目中有类似于以下代码的东西,我通过简单的单元测试进行测试.我没有实现await模式,但我不相信它与此相关.

public class RestApi()
{
    public void Get()
    {
        HttpResponseMessage response = new HttpResponseMessage();
        HttpClient client = new HttpClient();
        response = client.GetAsync("http://someUrl.com").Result;
        var modelList = response.Content.ReadAsAsync<List<Model>>().Result; // I get the exception here
     }
}
Run Code Online (Sandbox Code Playgroud)

对方法的调用:

var target = new RestApi();
target.Get();
Run Code Online (Sandbox Code Playgroud)

在这一点上我能做些什么吗?我不一定需要Async功能,所以另一个仍然将我的响应转换为我的模型的实现也可以.

c# rest json.net portable-class-library dotnet-httpclient

4
推荐指数
1
解决办法
1515
查看次数