We have a .NET 4 Website Project created using Visual Studio 2013, it references the System.Net.Http .dll.
This is the line in web.config that loads the .dll:
<add assembly="System.Net.Http, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
The project builds fine but when we try to “Publish Web Site” it gives the following error:
The type or namespace name ‘Http’ does not exist in the namespace ‘System.Net’ (are you missing an assembly reference?)
It looks like the assembly might be loading from the GAC, we have tried putting the assembly in the application’s BIN folder but this makes no difference – it is still showing as a GAC reference on the project property pages.
We have also tried adding:
<runtime>
<assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<codeBase version="1.0.0.0" href="/bin/System.Net.Http.dll"/>
</dependentAssembly>
</assemblyBinding>
As suggested here: Could not load file or assembly System.Web.Http.WebHost after published to Azure web site
But this does not seem to work either.
We have changed the Target Framework to 3.5 and 4.5 with no effect.
We have tried publishing from several different machines.
EDIT: We have tried the nuget package suggest in RobAda and it hasn't had the desired effect, we are still getting errors.
I have seen the same problem on a friends app, we needed to dig around quite a bit but eventually found that you need to install this nuget package:
https://www.nuget.org/packages/Microsoft.Net.Http
You will then need to add the reference to System.Net.Http for it to not produce the stated error.
Sound like you are trying to shoehorn something where it does not/cannot fit.
One possible architectural approach would be to separate the functionality out into a solution.
If time constraints are an issue and this is a possibility, it may be the solution to your problems.
Long term though: It would be worth ensuring that you keep up to date with the times as you will get more issues like this as time moves on, of course this must be approach pragmatically...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With