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.

By Rijwan Ansari

Research and Technology Lead | Software Architect | Full Stack .NET Expert | Tech Blogger | Community Speaker | Trainer | YouTuber. Follow me @ https://rijsat.com Md Rijwan Ansari is a high performing and technology consultant with 10 plus years of Software Development and Business Applications implementation using .NET Technologies, SharePoint, Power Platform, Data, AI, Azure and cognitive services. He is also a Microsoft Certified Trainer, C# Corner MVP, Microsoft Certified Data Analyst Associate, Microsoft Certified Azure Data Scientist Associate, CSM, CSPO, MCTS, MCP, with 15+ Microsoft Certifications. He is a research and technology lead in Tech One Global as well as leading Facebook community Cloud Experts Group and SharePoint User Group Nepal. He is a active contributor and speaker in c-sharpcorner.com community, C# Corner MVP and his rank at 20 among 3+ millions members. Additionally, he is knee to learn new technologies, write articles, love to contribute to the open-source community. Visit his blog RIJSAT.COM for extensive articles, courses, news, videos and issues resolution specially for developer and data engineer.

Leave a Reply

Your email address will not be published.