Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral on IIS

0

I started updating some nuget packages and started getting these warnings on build with a conflict for System.Net.Http. As suggested here:

Strange issue with System.Net.Http 4.2.0.0 not found

I replaced all references to System.Net.Http to use the nuget version, instead of the one bundled with Visual Studio. I then changed all redirect bindings (app.configs and web.configs) as suggested everywhere and I got things working locally. But..

When I deploy to our test server I still get the error

Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I´m using net 4.7.0 and Visual Studio 2017

I searched all my configs for a ref to Version 4.2.0.0 but no hits. Why does the IIS think it needs this one?

My nuget version of the System.Net.Http is 4.3.4 but the actual web.config has these lines

<dependentAssembly>
   <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
   <bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3"/>
</dependentAssembly> 

Again I can build and run it locally but my server reports the error.

UPDATE: I tried adding this on my servers web.config

 <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.1.1.3" />
  </dependentAssembly>

That makes the error go away! But I still dont get why i need to do this? Like why do my server think it needs to use 4.2.0?

asp.net
.net
asked on Stack Overflow Apr 8, 2019 by Jepzen • edited Apr 8, 2019 by Jepzen

1 Answer

0

I updated my solution to .NET Framework 4.7.2 and also made sure the server had this version installed. That solved my problems. After that i can remove the binding redirect.

answered on Stack Overflow Apr 20, 2019 by Jepzen • edited Jun 25, 2019 by Leniel Maccaferri

User contributions licensed under CC BY-SA 3.0