7

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)'

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.

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.

Has anyone seen this before?

dotnetdave82
  • 247
  • 2
  • 9
  • I found this. Didn't read it too closely, but might be your answer. http://stackoverflow.com/questions/10399324/where-is-httpcontent-readasasync – rory.ap Mar 18 '16 at 17:13
  • 1
    Thanks, but I have that NuGet package installed already but I'm still getting the error. – dotnetdave82 Mar 18 '16 at 17:17

2 Answers2

5

You might need to add a binding redirect in 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>
Guillermo Ruffino
  • 2,940
  • 1
  • 26
  • 23
3

I had the same issue and managed to resolve it by removing System.Net.Http NuGet package I had installed and installing Microsoft.Net.Http NuGet package instead (both provided by Microsoft).

igor_1024
  • 166
  • 1
  • 4