简体   繁体   English

HttpContentExtensions.ReadAsAsync错误

[英]HttpContentExtensions.ReadAsAsync Error

When making a method call to a generic method within the same class, I am getting the following exception: 在对同一个类中的泛型方法进行方法调用时,我收到以下异常:

System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task`1 System.Net.Http.HttpContentExtensions.ReadAsAsync(System.Net.Http.HttpContent)' System.MissingMethodException:找不到方法:'System.Threading.Tasks.Task`1 System.Net.Http.HttpContentExtensions.ReadAsAsync(System.Net.Http.HttpContent)'

The method call is as follows: 方法调用如下:

CarMdRootMessage<List<v20.CarMdDiagnosticReport>> report = this.CarMdGet<List<v20.CarMdDiagnosticReport>>(string.Format("report/diagnostic?uploadID={0}", string.Join(",", uploadIds)));

It looked like an issue with the "Microsoft.AspNet.WebApi.Client" NuGet package being out-of-sync between projects, but I have them all on 5.2.3 now and still have the issue. 看起来像“Microsoft.AspNet.WebApi.Client”NuGet包在项目之间不同步的问题,但是现在我已经将它们全部放在5.2.3上并且仍然存在问题。

I also thought this may be a .NET 4.5 issue so I've upgraded all projects to .NET 4.5.2, but I'm still getting the error. 我还认为这可能是一个.NET 4.5问题所以我已经将所有项目升级到.NET 4.5.2,但我仍然遇到错误。

Has anyone seen this before? 谁看过这个吗?

我遇到了同样的问题并设法通过删除我安装的System.Net.Http NuGet包 安装Microsoft.Net.Http NuGet包(均由Microsoft提供)来解决它。

You might need to add a binding redirect in app.config 您可能需要在app.config中添加绑定重定向

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
  </dependentAssembly>
</assemblyBinding>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM