[SOLVED] Could not load file or assembly 'System.Net.Http

Issue

In my diagnostic view of my build output shows this conflict

There was a conflict between “System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” and “System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”. (TaskId:20)
“System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” was chosen because it was primary and “System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” was not. (TaskId:20)
References which depend on “System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1\System.Net.Http.dll]. (TaskId:20)

I got here by adding the RestSharp nuget package. I was not having an issue until I installed this and I think one of the pieces that came with it may have caused this issue. I tried to uninstall it but that did not work.

Solution

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>

Answered By – Gerrie Pretorius

Answer Checked By – Timothy Miller (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *