This topic is a how to.
Please keep it as clear and simple as possible. Avoid speculative discussions as well as a deep dive into underlying mechanisms or related technologies.




Introduction

You can install and run multiple versions of the .NET Framework on a computer and each version can be installed in any order.
Starting from Windows XP, the operating system comes with a .NET Framework version installed and ready for use; the user can install a more recent version to get all the advantages that comes with the newest class libraries and namespaces provided by the most recent versions of the .NET Framework.

↑  Back to top

The Microsoft.NET\Framework Folder

Each .NET Framework version can be installed side-by-side and each version's files will be installed into a subfolder of the Windows main directory, identified by the environment variable %WINDIR%. To see which versions are installed, look into the %WINDIR% directory for the Microsoft.NET\Framework folder (you should also view the Framework64directory if you're running a 64-bit operating system, which can have 32 or 64-bit versions installed or both): each version of the .NET Framework has a directory and the first two digits of the directory name identify the .NET Framework version; for example: v1.1.4322 for the .NET Framework 1.1, v2.0.50727 for the .NET Framework 2.0, v3.5 for the .NET Framework 3.5 and so on.
Figure 1 depicts the folders containing the files for multiple .NET Framework version installed on a computer running Windows 7 Ultimate x64 Service Pack 1.

Figure 1: .NET Framework version specific subfolders.

↑  Back to top

Registry Keys

The informations related to the .NET Framework installation (along with the informations regarding the status of the installed Service Packs) are stored in the Windows registry under theHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP key. Figure 2 depicts the registry keys for multiple .NET Framework version installed on a computer running Windows 7 Ultimate x64 Service Pack 1.

Figure 2: .NET Framework version specific registry keys.

Table 1 provides a list of the stored values according to each installed .NET Framework version.

.NET Framework VersionService Pack LevelRegistry Key NameValue
4 - ClientOriginal ReleaseHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\ClientName: Install, Type:REG_DWORD, Data: 1
  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\ClientName: Version, Type: REG_SZ, Data: 4.0.30319.0
4 - FullOriginal ReleaseHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\FullName: Install, Type:REG_DWORD, Data: 1
  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\FullName: Version, Type: REG_SZ, Data: 4.0.30319.0
3.5Original ReleaseHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5Name: Install, Type:REG_DWORD, Data: 1
  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5Name: SP, Type:REG_DWORD, Data: 0
3.5Service Pack 1HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5Name: Install, Type:REG_DWORD, Data: 1
  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5Name: SP, Type:REG_DWORD, Data: 1
3.0Original ReleaseFollow the deployment and detection guidance in the document "Microsoft .NET Framework 3.0 Deployment Guide  " on the MSDN Library 
  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0Name: SP, Type:REG_DWORD, Data: 0
3.0Service Pack 1HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0Name: Install, Type:REG_DWORD, Data: 1
  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0Name: SP, Type:REG_DWORD, Data: 1
3.0Service Pack 2HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0Name: Install, Type:REG_DWORD, Data: 1
  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0Name: SP, Type:REG_DWORD, Data: 2
2.0Original ReleaseHKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727Name: Install, Type:REG_DWORD, Data: 1
  HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727Name: SP, Type:REG_DWORD, Data: 0
2.0Service Pack 1HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727Name: Install, Type:REG_DWORD, Data: 1
  HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727Name: SP, Type:REG_DWORD, Data: 1
2.0Service Pack 2HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727Name: Install, Type:REG_DWORD, Data: 1
  HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727Name: SP, Type:REG_DWORD, Data: 2
1.1 (on 32-bit operating systems)Original ReleaseHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322Name: Install, Type:REG_DWORD, Data: 1
  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322Name: SP, Type:REG_DWORD, Data: 0
1.1 (on 32-bit operating systems)Service Pack 1HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322Name: Install, Type:REG_DWORD, Data: 1
1.1 (on 64-bit operating systems)Original ReleaseHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322Name: Install, Type:REG_DWORD, Data: 1
  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322Name: SP, Type:REG_DWORD, Data: 0
1.1 (on 64-bit operating systems)Service Pack 1HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322Name: Install, Type:REG_DWORD, Data: 1
  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322Name: SP, Type:REG_DWORD, Data: 1
1.0 (on supported platforms except for Windows XP Media Center and Tablet PC)Original ReleaseHKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}Name: Version, Type: REG_SZ, Data: 1.0.3705.0
1.0 (on supported platforms except for Windows XP Media Center and Tablet PC)Service Pack 1HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}Name: Version, Type: REG_SZ, Data: 1.0.3705.1
1.0 (on supported platforms except for Windows XP Media Center and Tablet PC)Service Pack 2HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}Name: Version, Type: REG_SZ, Data: 1.0.3705.2
1.0 (on supported platforms except for Windows XP Media Center and Tablet PC)Service Pack 3HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}Name: Version, Type: REG_SZ, Data: 1.0.3705.3
1.0 (shipped with Windows XP Media Center 2002/2004 and Tablet PC 2004)Service Pack 2HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}Name: Version, Type: REG_SZ, Data: 1.0.3705.2
1.0 (shipped with Windows XP Media Center 2005 and Tablet PC 2005)Service Pack 3HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}Name: Version, Type: REG_SZ, Data: 1.0.3705.3

Table 1: .NET Framework version specific registry keys values.

To detect the existence of a specific .NET Framework version regardless of the Service Pack level, or to detect a service pack level or a later service pack level of the same .NET Framework version, use the registry information that listed Table 2.

.NET Framework VersionService Pack LevelRegistry Key NameValue
4 - ClientAny VersionHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\ClientInstall = 1
4 - FullAny VersionHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\FullInstall = 1
3.5Any VersionHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5Install = 1
3.5Service Pack 1 or GreaterHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5SP >= 1
3.0Any VersionHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0Install = 1
3.0Service Pack 1 or GreaterHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0SP >= 1
3.0Service Pack 2 or GreaterHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0SP >= 2
2.0Any VersionHKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727Install = 1
2.0Service Pack 1 or GreaterHKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727SP >= 1
2.0Service Pack 2 or GreaterHKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727SP >= 2
1.1Any VersionHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322Install = 1
1.1Service Pack 1HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322SP >= 1
1.0Any VersionHKEY_LOCAL_MACHINE\Software\Microsoft\.NET Framework\Policy\v1.0Name: 3705, Type: REG_SZ, exists
1.0 (on supported platforms except for Windows XP Media Center and Tablet PC)Service Pack 1 or GreaterHKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}Version >= 1.0.3705.1
1.0 (on supported platforms except for Windows XP Media Center and Tablet PC)Service Pack 2 or GreaterHKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}Version >= 1.0.3705.2
1.0 (on supported platforms except for Windows XP Media Center and Tablet PC)Service Pack 3 or GreaterHKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}Version >= 1.0.3705.3
1.0 (shipped with Windows XP Media Center 2002/2004 and Tablet PC 2004)Service Pack 2 or GreaterHKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}Version >= 1.0.3705.2
1.0 (shipped with Windows XP Media Center 2005 and Tablet PC 2005)Service Pack 3 or GreaterHKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}Version >= 1.0.3705.2

Table 2: .NET Framework version specific registry keys values regardless of the Service Pack level.

↑  Back to top

Determining the .NET Framework Version by Code

The .NET Framework version can be determined by writing code that queries the Common Language Runtime (CLR) version by using the Version property of the System.Environment  class, as in the following C# code snippet

using System;

class Sample
{
    public static void Main()
    {
      Console.WriteLine();
      Console.WriteLine("Version: {0}", Environment.Version.ToString());
    }
}

If you compile this program with the .NET Framework 3.5, this property's value will be "2.0.50727.3603".

↑  Back to top

The CLRVER Tool

The CLR Version tool (Clrver.exe) reports all the installed versions of the Common Language Runtime (CLR) on the computer. This tool is automatically installed with Visual Studio and with the Windows SDK and it must be executed from the Visual Studio Command Prompt or the Windows SDK Command Prompt.
At the command prompt type the following

clrver [option]

where [option] can be -all to display all the managed processes and the version of the CLR they are using, -? to display command syntax and options for the tool or pid to display the version(s) of the CLR used by the process that has the specified process ID. Running the tool with no options displays all installed CLR versions.

 

判断 4.5: https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx

摘自:http://social.technet.microsoft.com/wiki/contents/articles/15601.how-to-determine-the-net-framework-installed-versions.aspx