简体   繁体   中英

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 .

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. 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.

When developing in Visual Studio 2008 or 2010, you can choose which version of the .Net framework to use. 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. 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. 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. Multi-targeting helps guarantee that applications use only functionality that is available in the specified .NET Framework version. 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.

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.

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.

What matters is whether the .NET version installs side-by-side or update the existing version. Verions 1.0, 1.1, 2.0 and 4.0 are side-by-side versions. 3.0, 3.5, 3.5SP1 and the upcoming 4.5 are updates for the existing 2.0 and 4.0 versions. And use the same CLR version, the runtime version you are asking about. 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. The only way to get the update version is to read the registry, as shown in the question you linked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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