Could not load file or assembly System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Follow the following steps:
Update Visual Studio to to latest version (it matters)
Remove all binding redirects from
web.config
Add this to the
.csproj
file:<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>Build the project
In the
bin
folder there should be a(WebAppName).dll.config
fileIt should have redirects in it, copy these to the
web.config
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
Practical Applications of Bitwise Operations
What Does Default(Object); Do in C#
How to Run a .Net 4.5 App on Xp
What Are the Benefits of Resource(.Resx) Files
Dynamic MySQL Database Connection for Entity Framework 6
Get Error Message If Modelstate.Isvalid Fails
C#7: Underscore ( _ ) & Star ( * ) in Out Variable
The Type Arguments for Method Cannot Be Inferred from the Usage
Replace Unicode Escape Sequences in a String
Spawn Multiple Threads for Work Then Wait Until All Finished
Using Lambda Expressions for Event Handlers
What Is the Efficiency and Performance of Linq and Lambda Expression in .Net