Could Not Load File or Assembly "System.Net.Http, Version=4.0.0.0, Culture=Neutral, Publickeytoken=B03F5F7F11D50A3A"

Could not load file or assembly System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

Follow the following steps:

  1. Update Visual Studio to to latest version (it matters)

  2. Remove all binding redirects from web.config

  3. Add this to the .csproj file:

    <PropertyGroup>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    </PropertyGroup>
  4. Build the project

  5. In the bin folder there should be a (WebAppName).dll.config file

  6. It should have redirects in it, copy these to the web.config

  7. Remove the above snipped from the .csproj file

It should work.

Could not load file or assembly 'System.Net.Http

Installing Nuget Package: System.Net.Http version 4.3.3 installs the correct Version=4.1.1.2

this will result in the following reference in your project file:

<Reference Include="System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Net.Http.4.3.3\lib\net46\System.Net.Http.dll</HintPath>
</Reference>

Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral on IIS

I updated my solution to .NET Framework 4.7.2 and also made sure the server had this version installed. That solved my problems. After that i can remove the binding redirect.

Could not load file or assembly System.Net.Http, Version=4.0.0.0 with ASP.NET (MVC 4) Web API OData Prerelease

Visual Studio 2013 has a new feature to take care of this. When you build the app, you should see warnings about different versions of an assembly being referenced. Double click the warning to add assembly binding redirects to the web.config.

See http://msdn.microsoft.com/en-us/library/2fc472t2.aspx for more details.

jeff.eynon notes below that you need to have the web.config checked out (if using TFS source control) to get VS to edit the file automatically. Thanks for the tip!

Could not load file or assembly System.Net.Http version 4.1.1.0

Fixed it by updating System.Net.Http to 4.3.1



Related Topics



Leave a reply



Submit