Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly 'System.Net.Http, Version=4.1.1.1 .Net Standard

I am building a .Net standard library, which builds fine but on testing, I get this error

HResult=-2147024894 Message=Could not load file or assembly 'System.Net.Http, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Source=Library Trial

I have installed System.Net.Http Nuget Package still no success. It's a fresh project so what must I be doing wrong

like image 231
okeziestanley Avatar asked Aug 08 '17 08:08

okeziestanley


2 Answers

As Ved Tiwari said above, remove the reference to "4.1.1.1" in your app.config (or solution/project).

For example, I removed the below and it started working again:

<dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
</dependentAssembly>
like image 106
Rado Avatar answered Oct 11 '22 07:10

Rado


To fix that same error within my solution, not only did I remove the bindingRedirect for System.Net.Http from Web.config (see @Rado's answer) but also needed to remove Version, Culture, etc. and HintPath from it's reference in the project file (*.csproj).

Essentially, changed in *.csproj from

<Reference Include="System.Net.Http, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Net.Http.4.1.0\lib\net46\System.Net.Http.dll</HintPath>
</Reference>

to

<Reference Include="System.Net.Http"/>
like image 36
Ray Avatar answered Oct 11 '22 07:10

Ray