clr在构建时加载不同的程序集版本4.7.2而不是4.6.2 [英] clr loads a different assembly version 4.7.2 not 4.6.2 that is targeted when building

查看:80
本文介绍了clr在构建时加载不同的程序集版本4.7.2而不是4.6.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用visual studio创建一个以.net框架4.6.2为目标的项目,在运行我的应用程序时,我发现clr加载了mscorlib.dll程序集版本4.7.2,显然4.7.2是最新版本的程序集。但是为什么以及如何强制clr加载4.6.2
装配?

I use visual studio to create a project which targets .net framework 4.6.2,when running my app I have found clr loaded mscorlib.dll assembly version 4.7.2 ,obviously 4.7.2 is the newest version of assembly . But why and how can I force clr to load 4.6.2 assebmly?

推荐答案

这不是CLR的工作方式。一台机器上只有一个CLR v4,它是安装的任何版本。 4.6.2早于4.7.2,因此如果用户安装4.7.2,那么它将覆盖4.6.2运行时。

That isn't how the CLR works. There is only 1 CLR v4 on a machine and it is whatever version was installed. 4.6.2 is older than 4.7.2 so if a user installs 4.7.2 then it overwrites the 4.6.2 runtime.

重要的是要注意.NET框架和CLR在技​​术上是不同的。您的应用程序将以框架版本为目标,但它会针对运行时版本运行。 CLR只有3个版本(v1,v2和v4)。这个框架有很多版本
。框架版本用于工具支持并确定您运行的CLR版本。 .NET 1.x针对CLR v1运行,.NET 2.x和3.x针对v2运行,而.NET 4.x针对v4运行。 

It is important to note that the .NET framework and the CLR are technically different. Your app will target a framework version but it runs against the runtime version. There has been only 3 versions of the CLR (v1, v2 and v4). There have been many versions of the framework. The framework version is used for tooling support and to identify what version of the CLR you run against. .NET 1.x runs against CLR v1, .NET 2.x and 3.x run against v2 and .NET 4.x runs against v4. 

技术上任何.NET 4 .x app针对4.7.2运行。但是,较新的框架版本通常会引入新的配置设置,以在某些情况下调整CLR的行为。因此,有几种情况下CLR在运行app
时表现不同,但没有指定它支持4.7(或4.6或其他),但这并不常见。通常,应用程序运行4.7版本的运行时与4.6版本相同。

Technically any .NET 4.x app runs against 4.7.2. But newer framework versions generally introduce new config settings to adjust the behavior of the CLR in some cases. So there are a couple of cases where the CLR will behave differently when running an app that doesn't specify it supports 4.7 (or 4.6 or whatever) but this isn't common. In general apps run against 4.7 version of the runtime the same as they would the 4.6.

https://docs.microsoft.com/en-us/dotnet/framework/migration-guide / versions-and-dependencies

https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/versions-and-dependencies

https://blogs.msdn.microsoft.com/karinm/2008/11/10/whats-the-difference-between-clr-and-net -framework /

https://blogs.msdn.microsoft.com/karinm/2008/11/10/whats-the-difference-between-clr-and-net-framework/

总而言之,你无能为力。无论计算机上安装的CLR v4版本是应用程序运行的版本。

So, in summary, nothing you can do. Whatever version of the CLR v4 is installed on the machine is the version that the app will run against.


这篇关于clr在构建时加载不同的程序集版本4.7.2而不是4.6.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆