如何指定运行时加载的程序集版本 [英] How can I specify the assembly version loaded when running

查看:128
本文介绍了如何指定运行时加载的程序集版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用csharp和vs.项目目标创建了一个应用程序4.5.1并且它引用了mscorlib.dll程序集,但是当我运行应用程序时,加载的mscorlib.dll版本是4.7.2。我不知道为什么以及如何分析正确版本的程序集。

面对我只想让应用程序加载4.5.2版程序集,如mscorlib.dll或其他强名称组合。

非常感谢你。



我尝试过:



调试时我在VS中查找了程序集。

I have created a app using csharp and vs.The project targets to 4.5.1 and it refers to mscorlib.dll assembly, but when I run the app ,The loaded mscorlib.dll version is 4.7.2 . I dont know why and how can I sepcify the right version of assembly.
In face I just want the app load the 4.5.2 version assembly like mscorlib.dll or other strong named assemblyies.
Thank you so much.

What I have tried:

I have looked up the assemblies in VS when debugging.

推荐答案

您可以在您的参考节点上使用特定版本和复制本地强制使用特定版本的程序集的项目,但在这种情况下,您必须使用您的应用程序部署该程序集(可能它不在目标计算机上)...



顺便说一下:为什么?
You can use 'Specific Version' and 'Copy Local' on your reference node in your project to force to use a specific version of an assembly, however in this case you have to deploy that assembly with your application (maybe it is not on the target machine)...

And by the way: why?


从v4.0开始,每个新版本的.NET Framework都已作为就地升级发布,取代之前的任何版本v4.x install。



因此,如果您针对v4.5编译应用程序,并在安装了v4.7的计算机上运行它d,你的应用程序将在v4.7下运行,它将加载系统程序集的v4.7版本。



你无能为力改变那,你应该没有任何理由这样做。 Microsoft竭尽全力确保每个新版本都与以前的版本向后兼容。如果版本之间的行为发生变化,则针对旧版本编译的应用程序通常会获得较旧的行为。



如果您认为自己找到了真正的v4.5案例在v4.7下运行时应用程序被破坏,然后你需要向微软报告。
Since v4.0, each new version of the .NET Framework has been released as an "in-place upgrade", replacing any previous v4.x install.

Therefore, if you compile your application against v4.5, and run it on a computer with v4.7 installed, your application will be running under v4.7, and it will load the v4.7 versions of the system assemblies.

There is nothing you can do to change that, and there shouldn't be any reason for you to do so. Microsoft go to great lengths to ensure that each new version is backwards-compatible with the previous versions. In cases where the behaviour changes between versions, applications compiled against older versions typically get the older behaviour.

If you believe you have found a genuine case where your v4.5 application is broken when running under v4.7, then you'll need to report it to Microsoft.


这篇关于如何指定运行时加载的程序集版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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