Failed to load file or assembly "System.Net.Http" or one of its dependencies

Maybe relevant information: I have a web application that I created with .net 4.5. I wanted to deploy to Azure Web Sites, but it only supports .net 4.0, so I downgraded the project to .net 4.0. It still works on local startup.

When I publish to Azure, I get this error:

Failed to load file or assembly "System.Net.Http" or one of its dependencies. The located assembly manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I tried to remove the web API using nuget and read it, since another question about SO was suggested, but I still have the same problem.
I tried to close / open VS, and clear / build.

+6
source share
4 answers

I solved the problem with a similar problem (System.Web.Http and System.Net.Http.Formatting) by deleting the link to the link to the problem (which was pointed to my .Net installation folder) and replacing it with the link file in my package folder, which was installed by Microsoft.AspNet.WebApi NuGet.

+3
source

I had the same problem. However, updating assembly versions, copying local and specific version parameters did not help to solve my problem. In my application configuration, I am deploying a website and a worker role in a cloud service. After creating the service on the configure tab, I installed the operating system on Windows Server 2012 R2 to get support for the .Net Framework 4.5.1. But an error did occur.

In further research, I found that the * .cscfg file for my cloud service overloaded the portal settings with the obscure osFamily "3" setting. When I started my project, it was on MVC3 and did not yet have a WebAPI and framework 4.5.1. osFamily 3 was the last at that time.

In my last deployment, I upgraded my site to version 4.5.1 and MVC5. I verified that it worked locally on my development machine. But after deployment, this did not work with an error referring to System.Net.Http.Formatting version 4.0.0.0, which was not found. Later, I saw a deployment log that indicated a source error

"The NetFx451 feature required by the downloaded package is not available on the OS * selected for deployment.

Here is a blog article that led me to the decision to change the osFamily parameter to 4. Then my site worked after a new deployment.

http://tech.trailmax.info/2014/02/azure-deployment-the-feature-named-netfx451-that-is-required-by-the-uploaded-package-is-not-available-in-the- os-chosen-for-the-deployment /

+2
source

System.NET.HTTP.dll depends only on System.dll, System.Core.dll and mscorlib.dll.

Make sure you have this DLL (System.NET.HTTP.dll) in your deployment package (you can connect RDP and check the deployment folder). Play with the link "Copy to local" or include this DLL in your project at the root level and set the type to "content" in the properties .

Also System.Net.Http.dll is also supported for .NET 2.0, as I see it - this can cause a problem. Therefore, in addition to the above request, set the link property "Specific Version" = true

0
source

Azure now supports .Net 4.5 in the configuration tab. You can choose .Net framework version V3.5 or V4.5. I have several MVC web applications with numerous supporting DLL files, all of which are compiled in V4.5. What Azure does not support is V 4.5.1 (from VS 2013 RC release).

0
source

Source: https://habr.com/ru/post/924403/


All Articles