简体   繁体   English

*正在运行的框架版本*和运行时运行的*版本*之间有什么区别?

[英]What is the difference between *which version of the framework is running* and *which version of the runtime is running*?

In this post , @kbrimington mentions that there is a subtle difference between which version of the framework is running and which version of the runtime is running . 在这篇文章中 ,@ kbrimington提到框架正在运行的 版本与正在运行的运行时版本之间存在细微差别。

What is the difference exactly? 有什么区别?

Here is a quick breakdown that might give you the information you want. 这是一个快速细分,可能会为您提供所需的信息。 It can be confusing, but it is worth your time to understand the difference between all three and how they differ and interrelate. 这可能令人困惑,但值得花时间去理解这三者之间的差异以及它们之间的差异和相互关系。

CLR    .NET    C#  
----   ----    ----  
1.0    1.0     1.0  
1.0    1.1     1.0  
2.0    2.0     2.0  
2.0    3.0     3.0  
2.0    3.5     3.0  
4.0    4.0     4.0  
4.0    4.5     5.0

The .NET framework is the framework that describes the available classes. .NET框架是描述可用类的框架。 So the version of the framework tells you which classes are available. 所以框架的版本告诉你哪些类可用。

The runtime (CLR) is the part that executes the code, it is a virtual machine that translates your compiled application (MSIL) to a byte code that can be executed on the host OS. 运行时(CLR)是执行代码的部分,它是一个虚拟机,它将已编译的应用程序(MSIL)转换为可在主机操作系统上执行的字节代码。

When developing in Visual Studio 2008 or 2010, you can choose which version of the .Net framework to use. 在Visual Studio 2008或2010中进行开发时,您可以选择要使用的.Net框架版本。 This is called multi-targeting , as explained here and here : 这称为多目标定位 ,如此此处所述

The multi-targeting feature of Visual Studio lets you specify the specific version or profile of the .NET Framework that is required for your application. Visual Studio的多目标功能允许您指定应用程序所需的.NET Framework的特定版本或配置文件。 The key benefit of multi-targeting is that you can use the current version of Visual Studio to create and develop projects that target an earlier version of the .NET Framework. 多目标的主要好处是您可以使用当前版本的Visual Studio来创建和开发针对早期版本的.NET Framework的项目。 For example, you can continue to develop projects that were created in Visual Studio 2005 and Visual Studio 2008 without adding new .NET Framework dependencies. 例如,您可以继续开发在Visual Studio 2005和Visual Studio 2008中创建的项目,而无需添加新的.NET Framework依赖项。 Multi-targeting helps guarantee that applications use only functionality that is available in the specified .NET Framework version. 多目标有助于确保应用程序仅使用指定.NET Framework版本中提供的功能。 In addition, multi-targeting lets you continue to deploy older applications without requiring you to add a new .NET Framework version in your deployment package. 此外,多目标使您可以继续部署较旧的应用程序,而无需在部署包中添加新的.NET Framework版本。

An app compiled on .Net 3.5 in Visual Studio 2008 will use a different version of the runtime from the same app compiled on .Net 3.5 in Visual Studio 2010. 在Visual Studio 2008中.Net 3.5上编译的应用程序将使用Visual Studio 2010中.Net 3.5上编译的同一应用程序的不同版本的运行时。

This means that, when you are supporting or enhancing apps written in older versions of .Net or Visual Studio, you can still do that development in a newer version of Visual Studio, taking advantage of the newer features. 这意味着,当您支持或增强使用旧版本的.Net或Visual Studio编写的应用程序时,您仍然可以在较新版本的Visual Studio中进行该开发,并利用较新的功能。

What matters is whether the .NET version installs side-by-side or update the existing version. 重要的是.NET版本是并排安装还是更新现有版本。 Verions 1.0, 1.1, 2.0 and 4.0 are side-by-side versions. Verions 1.0,1.1,2.0和4.0是并排版本。 3.0, 3.5, 3.5SP1 and the upcoming 4.5 are updates for the existing 2.0 and 4.0 versions. 3.0,3.5,3.5SP1和即将发布的4.5是现有2.0和4.0版本的更新。 And use the same CLR version, the runtime version you are asking about. 并使用相同的CLR版本,即您要询问的运行时版本 The updates add extra assemblies. 更新添加了额外的程序集。 You cannot otherwise have, say, both 2.0 and 3.0 installed at the same time, the 3.0 update replaces 2.0. 你不能同时安装2.0和3.0,3.0更新取代2.0。 The only way to get the update version is to read the registry, as shown in the question you linked. 获取更新版本的唯一方法是阅读注册表,如您链接的问题所示。

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

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