I need to upgrade my WebApi2 project from 4.7.1 to 4.8 so I did the following:
- Changed the
Target Framework
to 4.8 in the Properties tab - Changed 'targetFramework="net471"' to '"targetFramework=net48"' in the
packages.config
- Deleted bin and obj folders, and then did a
nuget restore
- Checked that all referenced files under
References\Assemblies
point to the SDKv4.8
folder - Rebuilt the solution
Then 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
?