I'm trying to update my Web API from 2.0 to 2.1 but I have the following error
Could not load file or assembly 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at this line
GlobalConfiguration.Configure(WebApiConfig.Register);
in the global.asax.cs
when I run the API after the update.
but it's normal because it's referencing 5.1.0 in the csprog
<Reference Include="System.Web.Http, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
I tried also with the command line
Install-Package Microsoft.AspNet.WebApi -Version 5.1.0
and I have the same problem but sometimes it gives me an error saying that some plugins depend on Microsoft.AspNet.WebApi.core 5.0.0.
but I don't understand why because the plugin's dependencies are Microsoft.AspNet.WebApi.core >= 5.0.0.
so 5.1.0 should work.
I tried to update and ignore dependencies with
Install-Package -Ignoredependencies Microsoft.AspNet.WebApi -Version 5.1.0
and I don't have the error anymore but the API returns error 500.
Any idea why the update to Web API 2.1 doesn't work?
Do you have assembly binding redirect?
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With