简体   繁体   English

Azure应用服务 - 无法加载文件或程序集'System.Net.Http,Version = 4.2.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'

[英]Azure app service - Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Getting an 得到一个

Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. 无法加载文件或程序集'System.Net.Http,Version = 4.2.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一。 The system cannot find the file specified." exception after publishing to Azure as an App Service. 系统找不到指定的文件。“作为App Service发布到Azure后出现异常。

I have created a ASP.NET Wep API application using Entity Framework DB First approach. 我使用Entity Framework DB First方法创建了一个ASP.NET Wep API应用程序。 I did not use any NuGet package to install System.Net.Http, it was added automatically when the project was created. 我没有使用任何NuGet包来安装System.Net.Http,它是在创建项目时自动添加的。 The latest version is 4.2.0.0. 最新版本是4.2.0.0。

It works fine when I run on my local IIS (IIS Express). 当我在本地IIS(IIS Express)上运行时,它工作正常。

I published this app as an Azure App Service successfully but it does not open the API Home page. 我已成功将此应用程序作为Azure应用程序服务发布,但它未打开API主页。 Instead I get the above mentioned exception. 相反,我得到了上面提到的例外。

I tried using bindingRedirect in Web.config but it does not help. 我尝试在Web.config中使用bindingRedirect,但它没有帮助。

I am new to Azure and not sure how the dlls are deployed. 我是Azure的新手,不知道如何部署dll。 Any help is greatly appreciated. 任何帮助是极大的赞赏。

Upgraded project to 4.7.2. 升级后的项目为4.7.2。

Turns out Visual Studio 2017, when installing the .NET 4.3.3 Nuget package for System.Net.HTTP is also adding DLL reference from the GAC. 当为System.Net.HTTP安装.NET 4.3.3 Nuget包时,结果是Visual Studio 2017.HTTP也在从GAC添加DLL引用。 This in tandem with an Assembly redirect causes run time System.IO.FileNotFoundException looking for version 4.2.0.0 of System.Net.Http. 这与程序集重定向一起导致运行时System.IO.FileNotFoundException查找System.Net.Http的版本4.2.0.0。

The good news, is to add references, uncheck System.Net.Http from the GAC (which was added automatically or by other developers in the project at one point in time), and simply delete the Assembly redirect. 好消息是添加引用, 取消选中GAC中的System.Net.Http (在一个时间点自动添加或由项目中的其他开发人员添加),并简单地删除程序集重定向。

For more details, you could refer to this article . 有关更多详细信息,请参阅此文章

I think found the cause of the issue. 我认为找到了问题的原因。 My project is using .Net framework version 4.7.2 and on Azure the app service is using .Net framework version 4.7. 我的项目使用的是.Net framework版本4.7.2,而在Azure上,应用服务正在使用.Net framework版本4.7。 So changing the target framework in my project properties to 4.7 seems to work. 因此,将项目属性中的目标框架更改为4.7似乎可行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集“System.Net.Http,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a” - Could not load file or assembly "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 未找到此程序集:“System.Net.Http,版本=4.0.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a” - This assembly is not found: 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' NET 核心 - 无法加载文件或程序集'System.Runtime,版本 = 6.0.0.0,文化 = 中性,PublicKeyToken = b03f5f7f11d50a3a',.NET 6 - NET core - Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ', .NET 6 '无法加载文件或程序集'System.Runtime,版本= 4.1.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a' - 'Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 无法加载文件或程序集“System.IO,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一 - Could not load file or assembly 'System.IO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies 无法加载文件或程序集“System.Runtime,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一 - Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies 无法加载文件或程序集“ System.Configuration,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a”或其依赖项之一 - Could not load file or assembly 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies linqpad无法加载文件或程序集'System.Runtime,版本= 4.1.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a' - linqpad Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 无法加载文件或程序集“System.Runtime,版本=4.2.1.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a” - Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 无法加载文件或程序集“ Microsoft.VisualStudio.Services.Common,版本= 12.0.21005.1,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a” - Could not load file or assembly “Microsoft.VisualStudio.Services.Common, Version=12.0.21005.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM