title: Type argument 'System.Net.Http.Headers.MediaTypeHeaderValue' violates the constraint of type parameter 'T'
body: <p>I have a Web API solution (targeting .NET 4.6) with a couple of fairly lightweight .NET Core projects in it. I've packaged the .NET Core projects up as a NuGet package and installed them to the Web API project.</p>
  
  <p>Everything builds fine, but when running it, I get the following exception when the application is initialising.</p>
  
  <pre><code>Method System.Net.Http.CloneableExtensions.Clone: type argument 'System.Net.Http.Headers.MediaTypeHeaderValue' violates the constraint of type parameter 'T'.
  
  [VerificationException: Method System.Net.Http.CloneableExtensions.Clone: type argument 'System.Net.Http.Headers.MediaTypeHeaderValue' violates the constraint of type parameter 'T'.]
     System.Net.Http.Formatting.MediaTypeConstants.get_ApplicationJsonMediaType() +0
     System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor() +64
     System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters() +41
     System.Web.Http.HttpConfiguration.DefaultFormatters(HttpConfiguration config) +26
     System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection routes) +214
     System.Web.Http.GlobalConfiguration.&lt;CreateConfiguration&gt;b__0() +60
     System.Lazy`1.CreateValue() +411
     System.Lazy`1.LazyInitValue() +183
     System.Lazy`1.get_Value() +75
     System.Web.Http.GlobalConfiguration.get_Configuration() +27
     Runpath.Platform.Web.DependencyResolution.StructureMapBootStrapper.Initialise() in C:\Code3\Runpath\Markets\Platform\Main - Copy\Runpath.Platform.Web\DependencyResolution\StructureMapBootStrapper.cs:15
     Runpath.Platform.Web.WebApiApplication.Application_Start() in C:\Code3\Runpath\Markets\Platform\Main - Copy\Runpath.Platform.Web\Global.asax.cs:30
  
  [HttpException (0x80004005): Method System.Net.Http.CloneableExtensions.Clone: type argument 'System.Net.Http.Headers.MediaTypeHeaderValue' violates the constraint of type parameter 'T'.]
     System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +493
     System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
     System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +176
     System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +364
     System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +303
  
  [HttpException (0x80004005): Method System.Net.Http.CloneableExtensions.Clone: type argument 'System.Net.Http.Headers.MediaTypeHeaderValue' violates the constraint of type parameter 'T'.]
     System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +770
     System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
     System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +195
  </code></pre>
  
  <p>I've checked in Object Browser, and <code>MediaTypeHeaderValue</code> does implement <code>ICloneable</code>. Any ideas what could be causing this?</p>
  
  <p>I should also say that it's fine when I replace the .NET Core projects with .NET 4.6 versions.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>As per Johnathan's response, I managed to get it working by updating project.json to use System.Net.Http 4.0.0.0 for .NET 4.6:</p>
  
  <pre><code>{
    "version": "1.0.3-*",
  
    "dependencies": {
      "NETStandard.Library": "1.6.0"
    },
  
    "frameworks": {
      "net46": {
        "dependencies": {
          "System.Net.Http": "4.0.0"
        }
      },
      "netstandard1.6": {
        "imports": "dnxcore50"
      }
    }
  }
  </code></pre>