Failed to load file or assembly "System.Web.Http, Version = 5.2.2.0

I added the Odada v4 package to my API, I noticed that it updated my Microsoft.AspNet.WebApi package to version 5.2.3 . But when I try to use

The odata linker configuration in my WebApiConfig shows an error, for example, 'Failed to load file or assembly' System.Web.Http, Version = 5.2.2.0 ' .

config.MapODataServiceRoute("odata", null, GetEdmModel(), new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)); 

I searched for this version (5.2.2) in my project, but every thing is 5.2.3, and I also updated all the packages to solve this problem, but failed. Copy to local property is also true for System.Web.Http dll.
Any idea?

+6
source share
2 answers

Visual Studio solved this for me. Version conflicts appear as a warning, and when I clicked, it automatically added a binding redirect to my web configuration.

https://msdn.microsoft.com/en-us/library/2fc472t2.aspx

The binding redirection that resolved my issue,

 <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.2.3.0" newVersion="5.2.3.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31BF3856AD364E35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> </dependentAssembly> </assemblyBinding> 
+7
source

Well, this is not a "real" solution, but a workaround: I changed the machine.config file and replaced <runtime /> with

  <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.2.3.0" newVersion="5.2.3.0" /> </dependentAssembly> </assemblyBinding> </runtime> 

so I work, but if you have other websites running ...

0
source

All Articles