Could not load file or assembly System.Net.Http, Version=4.0.0.0 in .Net

Dung Do Tien May 31 2022 248

Hello guys. I have a project with C# Asp.Net Framework version 4.7.2. I used Github to help manage source code and my project still works well for me. And today I created a branch that bases on from master branch. But when running the project I got an error Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral,  PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

 Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. 
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  at BookManager.modENS.GetENSResolver_BookAddress(String nameHash) in C:\Project\BookManager\BookManager.IO\Source_SecondTask\BookManager\common\BudENS.cs:line 59
  at BookManager.enslookup_search.LoadPageForAddress(String address) in C:\Project\BookManager\BookManager.IO\Source_SecondTask\BookManager\enslookup-search.aspx.cs:line 120 

My project installed  System.Net.Http version 4.2.0.0, I search all the projects but did not find any package with version 4.0.0.0.

Here is a bit of  my web.config  file:

 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Google.Apis" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.38.0.0" newVersion="1.38.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Google.Apis.Auth" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.38.0.0" newVersion="1.38.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

I used VS 2022 and windows 11.

I tried downgrading to version 4.0.0.0 but it still didn't work for me.

Please support me if you know any solution.

Have 1 answer(s) found.
  • T

    Trần quốc cường May 31 2022

    I really got the same error as you. After trying many solutions that did not work, I found a simple way, like this:

    Step 1: Open your web.config file and delete this line:

     <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
    </dependentAssembly>

    Step 2: Clear, rebuild project and rerun project. Your issues will be solved.

    It's worked for me and hopefully also worked for you.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close