Problem
My project was moved to a new Windows 10 system that only has Visual Studio 2015 Community and SQL Server 2016 Express installed. Apart from those included with Windows 10 and Visual Studio 2015 or SQL Server, no other framework versions are installed.
When I attempt to start the WebApi project, I receive the following message:
The following are some of the project’s packages:
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Tracing" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
System.Net.Http is missing from the bin folder after constructing the app with.NET Framework 4.6.1.
The file’s path is as follows:
System.Net.Http.file Formatting’s path is as follows:
Is it necessary to target 4.5.1 for the entire project, or is there another method to reference the correct assemblies?
Asked by Ivan-Mark Debono
Solution #1
Changing the binding information in my web.config (or app.config) allows you to continue working on your project after a NuGet package update whacks your application and gives you the System.Net.Http error.
Assign the following values to oldVersion=”0.0.0.0-4.1.1.0″ and newVersion=”4.0.0.0″:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.0.0.0" />
</dependentAssembly>
Answered by tripletdad99
Solution #2
Follow the steps below.
It should work
Answered by Sajeetharan
Solution #3
There was a nuget package with a higher version of System.Net.Http in one of my projects, and there was a reference to System.Net.Http v 4.0.0 in my startup project, so I just installed the System.Net.Http nuget package in my starter project and the problem was solved.
Answered by Ram Y
Solution #4
Change following:
<bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
with the following:
<bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.0.0.0" />
in web.config
Answered by Muhammad Waqas
Solution #5
Because the above bind-redirect did not work for me, I commented out the System.Net.Http reference in web.config. Everything appears to function normally without it.
<system.web>
<compilation debug="true" targetFramework="4.7.2">
<assemblies>
<!--<add assembly="System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />-->
<add assembly="System.ComponentModel.Composition, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
<customErrors mode="Off" />
<httpRuntime targetFramework="4.7.2" />
</system.web>
Answered by Mark
Post is based on https://stackoverflow.com/questions/38408167/could-not-load-file-or-assembly-system-net-http-version-4-0-0-0-culture-neutr