Type argument 'System.Net.Http.Headers.MediaTypeHeaderValue' violates the constraint of type parameter 'T'

It was not immediately clear to me what to do when I read the correct answer above - For those running into the same issue : just change/add the mapping in your app.config / web.config in the configuration/runtime/assemblyBinding section:

  <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>

UPDATE

.Net core team updated System.Net.Http package to 4.3.1 on 21/2/2017. So if you can update you shouldn't need this redirect anymore.

Details of the issue: https://github.com/dotnet/corefx/issues/11100


It's an issue with the latest NuGet version of System.Net.Http. For now, either downgrade the System.Net.Http to v4.0.0.0 or use the version built into Framework 4.6.

https://github.com/dotnet/corefx/issues/9884