我有一个在完整的 Framework 4.6.1上运行的asp core 2.0应用程序。它在本地运行良好,但是当我将其部署到Azure时,出现以下错误:
I have an asp core 2.0 application that runs on full framework 4.6.1. It works fine locally but when I deploy it to Azure I receive the following error:
FileLoadException:无法加载文件或程序集'System。运行时,版本= 4.2.0.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常: 0x80131040)
FileLoadException: Could not load file or assembly 'System.Runtime, 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)
在Debug / Release文件夹中,我有System.Runtime 4.1.2.0,但以某种方式
In Debug/Release folder I have System.Runtime 4.1.2.0 but somehow it works.
在经典 .NET框架中,我曾经将程序集重定向添加到app.config中,但是这里没有web.config。知道如何解决该问题吗?
In "classic" .NET framework I used to add assembly redirect to app.config but here I don't have web.config. Any idea how to fix that?
推荐答案如果您创建针对 [。NET Core] 平台,部署到Azure(或本地部署),然后将其更改为以 [。NET Framework] $ c为目标
This can happen if you create an ASP.NET Core 2.0 Web Application that targets the [.NET Core] platform, deploy to Azure (or deploy locally), and then change it to target the [.NET Framework] instead.
例如如果您更改
<PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> </PropertyGroup>至
<PropertyGroup> <TargetFramework>net461</TargetFramework> </PropertyGroup>但是如果您在重新部署之前不从Azure中删除现有文件,您会出现此错误。
but if you do not delete the existing files from Azure before redeploying you will get this error.
在以下情况下也可能发生:
It can also happen in the following scenario:
-
首先使用Visual Studio 2017创建一个.NET Core项目,
First create a .NET Core project with Visual Studio 2017 with:
File-> New Project-> Visual C#> Web> Asp.NET Core Application`
File -> New Project -> Visual C# > Web > Asp.NET Core Application`
在第二个屏幕上选择 [。NET Core] 平台。
Choose the [.NET Core] Platform on the Second Screen.
- 将Web应用程序部署到Azure。
-
然后创建一个新项目
- Deploy the web app to Azure.
Then create a new Project with :
文件->新项目-> Visual C#> Web> Asp.NET Core应用程序
File -> New Project -> Visual C# > Web > Asp.NET Core Application`
在第二个屏幕上选择.NET Framework设置。
Choose the .NET Framework setting on the Second Screen.
重新部署而不删除Azure中的现有文件将导致此错误。
Redeploy without deleting the existing files from Azure will cause this error.
希望有帮助。
更多推荐
FileLoadException:无法加载文件或程序集System.Runtime,版本= 4.2.0.0
发布评论