FileLoadException:无法加载文件或程序集System.Runtime,版本= 4.2.0.0

编程入门 行业动态 更新时间:2024-10-28 06:29:38
本文介绍了FileLoadException:无法加载文件或程序集System.Runtime,版本= 4.2.0.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个在完整的 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]

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

本文发布于:2023-11-03 06:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554430.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   版本   文件   程序   FileLoadException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!