Sometimes, we get this kind of error in asp.net while publishing a solution in IIS or running locally.
Could not load file or assembly ‘System.Net.Http.Formatting’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
This error can be because of few reasons.
- The main reason is the application is not able to load the library or dll.
- This could be because of different versions (version miss-match or lower-upper)
- The reference of assemble or dll location is incorrect.
- Depending of asp.net web api, version might gets changed
- web.config file might have different version in published solution
In my case, the reason was different version in web.config. I had updated the solution with some changes and released in IIS. However, I didn’t check the version in web.config and didn’t update the web.config file.
In my case, I simply update the web.config file based on local solution. I have to upgrade the version in web.config file.
<dependentAssembly> <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-126.96.36.199" newVersion="188.8.131.52" /> </dependentAssembly>
It fixed the issue. We need to compare version of the deployed application with a local development one.
However, if you are facing issue again in local as well as the deployed solution, then reinstall from NuGet package.