gpt4 book ai didi

.net - FileLoadException : Could not load file or assembly System.运行时,版本= 4.2.0.0

转载 作者:行者123 更新时间:2023-12-04 23:10:06 30 4
gpt4 key购买 nike

我有一个在完整的.net Framework 4.6.1上运行的asp.net core 2.0应用程序。它在本地运行良好,但是当我将其部署到Azure时,出现以下错误:

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,但它以某种方式起作用。

在“经典” .NET框架中,我曾经将程序集重定向添加到app.config,但这里没有web.config。任何想法如何解决?

最佳答案

如果您创建针对[.NET Core]平台的ASP.NET Core 2.0 Web应用程序,将其部署到Azure(或本地部署),然后将其更改为针对[.NET Framework],则可能会发生这种情况。

例如如果你改变

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>


<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>

但是,如果您 不要在重新部署之前从Azure中删除现有文件,则会出现此错误。

在以下情况下也可能发生:
  • 首先使用Visual Studio 2017创建一个.NET Core项目,其内容如下:

    文件->新项目-> Visual C#> Web> Asp.NET Core应用程序
  • 在第二个屏幕上选择[.NET Core]平台。


  • 将Web应用程序部署到Azure。
  • 然后使用以下命令创建一个新项目:

    文件->新项目-> Visual C#> Web> Asp.NET Core应用程序
  • 在第二个屏幕上选择.NET Framework设置。


  • 重新部署而不从Azure中删除现有文件将导致此错误。

    希望能有所帮助。

    关于.net - FileLoadException : Could not load file or assembly System.运行时,版本= 4.2.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45894659/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com