简体   繁体   English

库将在哪个.net框架版本中运行

[英]Which .net framework version will a library run in

If i have a library which is compiled in .NET 4 and reference it from a .net 4.5 executable which version of the framework will operations defined in the library execute against? 如果我有一个在.NET 4中编译并从.net 4.5可执行文件引用的库,则库中定义的操作将针对哪个版本的框架执行?

I have a cli app which is built in .net 4.5 and references both .net 4 and .net 4.5 projects and im wondering if both will use the same version of the ADO.net components. 我有一个内置于.net 4.5中的cli应用程序,它同时引用.net 4和.net 4.5项目,我想知道两者是否都将使用相同版本的ADO.net组件。

They will both run in the same CLR (4.5 in this case). 它们都将在同一CLR中运行(本例中为4.5)。

With .NET <=3.5, you could have cases where multiple versions of the same assembly will be loaded (so, it could happen that ADO.NET will load version 4.0 and also load 4.5 in the same app domain). 如果使用.NET <= 3.5,则可能会加载同一程序集的多个版本(因此,ADO.NET可能会加载版本4.0,同时还会在同一应用程序域中加载4.5)。 As far as I know, they either eliminated that with CLR 4.0 (or at least made it happen way less). 据我所知,他们要么在CLR 4.0中消除了这一点(要么至少使它发生的可能性降低了)。

Edit: BTW - there's a difference between the CLR (the runtime running your code) and the versions of the assemblies being loaded. 编辑:顺便说一句-CLR(运行您的代码的运行时)与要加载的程序集的版本之间存在差异。

The version of the CLR governs the capabilities of the process - what it can do, which versions of assemblies it can load. CLR的版本控制流程的功能-它可以做什么,可以加载程序集的哪些版本。 For example,, CLR 4.5 can load pretty much all assemblies (1.0 -> 4.5). 例如,CLR 4.5可以加载几乎所有程序集(1.0-> 4.5)。 They will all run under the 4.5 CLR. 它们都将在4.5 CLR下运行。 On top of that, you cannot run two versions of the CLR from the same compat band in the same process. 最重要的是,您不能在同一过程中从同一兼容波段运行两个版本的CLR。 CLR 4.5 and 4.0 both are considered the same compat band, so either one or the other will load. CLR 4.5和4.0都被视为相同的兼容频带,因此一个或另一个将加载。 CLR 1.0, 1.1, 2.0, 3.0 and 3.5 are all considered in the same compat band, so only one of them can load. CLR 1.0、1.1、2.0、3.0和3.5都被视为在同一兼容频带中,因此只能加载其中之一。 You can, however, load CLR 3.5 and CLR 4.5 at the same time. 但是,您可以同时加载CLR 3.5和CLR 4.5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM