Reputation: 16310
I need to upgrade my WebApi2 project from 4.7.1 to 4.8 so I did the following:
Target Framework
to 4.8 in the Properties tabpackages.config
nuget restore
References\Assemblies
point to the SDK v4.8
folderThen I changed the following in web.config
:
<system.web>
<compilation debug="true" targetFramework="4.8"/>
<httpRuntime targetFramework="4.8"/>
</system.web>
However I get an exception when running the project:
Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
The corresponding section in web.config
is:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0"/>
</dependentAssembly>
The project is part of a larger solution and it references projects which target netstandard2.0
. This is however not the problem, because everything was working when still using 4.7.1
Where / what else do I need to check / change to make get the project going using v4.8
?
Upvotes: 2
Views: 2676
Reputation: 16310
Following the steps as per @Igor 's comment reference the Could not load file or assembly “System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” solves the problem.
Definitely the best solution.
Upvotes: 2