Sometimes, we get this kind of error in asp.net while publishing a solution in IIS or running locally.

Exact Error
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.
Solution
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-5.2.3.0" newVersion="5.2.3.0" />
</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.
No comments:
Post a Comment