| title | How to: Determine which .NET Framework versions are installed | ||
|---|---|---|---|
| ms.date | 01/24/2018 | ||
| ms.prod | .net-framework | ||
| ms.technology |
|
||
| ms.topic | article | ||
| dev_langs |
|
||
| ms.custom | updateeachrelease | ||
| helpviewer_keywords |
|
||
| ms.assetid | 40a67826-e4df-4f59-a651-d9eb0fdc755d | ||
| author | rpetrusha | ||
| ms.author | ronpet | ||
| manager | wpickett | ||
| ms.workload |
|
Users can install and run multiple versions of the .NET Framework on their computers. When you develop or deploy your app, you might need to know which .NET Framework versions are installed on the user’s computer. Note that the .NET Framework consists of two main components, which are versioned separately:
-
A set of assemblies, which are collections of types and resources that provide the functionality for your apps. The .NET Framework and assemblies share the same version number.
-
The common language runtime (CLR), which manages and executes your app's code. The CLR is identified by its own version number (see Versions and Dependencies).
To get an accurate list of the .NET Framework versions installed on a computer, you can view the registry or query the registry in code:
Viewing the registry (versions 1-4)
Viewing the registry (version 4.5 and later)
Using code to query the registry (versions 1-4)
Using code to query the registry (version 4.5 and later)
Using PowerShell to query the registry (version 4.5 and later)
To find the CLR version, you can use a tool or code:
Using the Clrver tool
Using code to query the System.Environment class
For information about detecting the installed updates for each version of the .NET Framework, see How to: Determine Which .NET Framework Updates Are Installed. For information about installing the .NET Framework, see Install the .NET Framework for developers.
-
On the Start menu, choose Run.
-
In the Open box, enter regedit.exe.
You must have administrative credentials to run regedit.exe.
-
In the Registry Editor, open the following subkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDPThe installed versions are listed under the NDP subkey. The version number is stored in the Version entry. For the [!INCLUDEnet_v40_long] the Version entry is under the Client or Full subkey (under NDP), or under both subkeys.
[!NOTE] The "NET Framework Setup" folder in the registry does not begin with a period.
-
On the Start menu, choose Run.
-
In the Open box, enter regedit.exe.
You must have administrative credentials to run regedit.exe.
-
In the Registry Editor, open the following subkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\FullNote that the path to the
Fullsubkey includes the subkeyNet Frameworkrather than.NET Framework.[!NOTE] If the
Fullsubkey is not present, then you do not have the .NET Framework 4.5 or later installed.Check for a DWORD value named
Release. The existence of theReleaseDWORD indicates that the [!INCLUDEnet_v45] or newer has been installed on that computer.The value of the
ReleaseDWORD indicates which version of the .NET Framework is installed.[!INCLUDERelease key values note]
Value of the Release DWORD Version 378389 .NET Framework 4.5 378675 .NET Framework 4.5.1 installed with Windows 8.1 or Windows Server 2012 R2 378758 .NET Framework 4.5.1 installed on Windows 8, Windows 7 SP1, or Windows Vista SP2 379893 .NET Framework 4.5.2 On Windows 10 systems: 393295
On all other OS versions: 393297[!INCLUDEnet_v46] On Windows 10 November Update systems: 394254
On all other OS versions: 394271[!INCLUDEnet_v461] On Windows 10 Anniversary Update: 394802
On all other OS versions: 394806[!INCLUDEnet_v462] On Windows 10 Creators Update: 460798
On all other OS versions: 460805.NET Framework 4.7 On Windows 10 Fall Creators Update: 461308
On all other OS versions: 461310.NET Framework 4.7.1
-
Use the xref:Microsoft.Win32.RegistryKey?displayProperty=nameWithType class to access the Software\Microsoft\NET Framework Setup\NDP\ subkey under HKEY_LOCAL_MACHINE in the Windows registry.
The following code shows an example of this query.
[!NOTE] This code does not show how to detect the [!INCLUDEnet_v45] or later. Check the
ReleaseDWORD to detect those versions, as described in the previous section. For code that does detect the [!INCLUDEnet_v45] or later versions, see the next section in this article.[!code-csharpListVersions] [!code-vbListVersions]
The example produces output that's similar to the following:
v2.0.50727 2.0.50727.4016 SP2 v3.0 3.0.30729.4037 SP2 v3.5 3.5.30729.01 SP1 v4 Client 4.0.30319 Full 4.0.30319
-
The existence of the
ReleaseDWORD indicates that the .NET Framework 4.5 or later has been installed on a computer. The value of the keyword indicates the installed version. To check this keyword, use the xref:Microsoft.Win32.RegistryKey.OpenBaseKey%2A and xref:Microsoft.Win32.RegistryKey.OpenSubKey%2A methods of the xref:Microsoft.Win32.RegistryKey?displayProperty=nameWithType class to access the Software\Microsoft\NET Framework Setup\NDP\v4\Full subkey under HKEY_LOCAL_MACHINE in the Windows registry. -
Check the value of the
Releasekeyword to determine the installed version. To be forward-compatible, you can check for a value greater than or equal to the values listed in the table. Here are the .NET Framework versions and associatedReleasekeywords.[!INCLUDERelease key values note]
Version Value of the Release DWORD .NET Framework 4.5 378389 .NET Framework 4.5.1 installed with Windows 8.1 378675 .NET Framework 4.5.1 installed on Windows 8, Windows 7 SP1, or Windows Vista SP2 378758 .NET Framework 4.5.2 379893 .NET Framework 4.6 installed with Windows 10 393295 .NET Framework 4.6 installed on all other Windows OS versions 393297 .NET Framework 4.6.1 installed on Windows 10 394254 .NET Framework 4.6.1 installed on all other Windows OS versions 394271 .NET Framework 4.6.2 installed on Windows 10 Anniversary Update 394802 .NET Framework 4.6.2 installed on all other Windows OS versions 394806 .NET Framework 4.7 installed on Windows 10 Creators Update 460798 .NET Framework 4.7 installed on all other Windows OS versions 460805 .NET Framework 4.7.1 installed on Windows 10 Fall Creators Update 461308 .NET Framework 4.7.1 installed on all other Windows OS versions 461310 The following example checks the
Releasevalue in the registry to determine whether the [!INCLUDEnet_v45] or a later version of the .NET Framework is installed.[!code-csharpListVersions#5] [!code-vbListVersions#5]
This example follows the recommended practice for version checking:
-
It checks whether the value of the
Releaseentry is greater than or equal to the value of the known release keys. -
It checks in order from most recent version to earliest version.
-
To check for a minimum-required .NET Framework version by querying the registry in PowerShell (.NET Framework 4.5 and later)
-
The following example checks the value of the
Releasekeyword to determine whether .NET Framework 4.6.2 or higher is installed, regardless of Windows OS version (returningTrueif it is andFalseotherwise).Get-ChildItem "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\" | Get-ItemPropertyValue -Name Release | ForEach-Object { $_ -ge 394802 }
You can replace
394802in the previous example with another value from the following table to check for a different minimum-required .NET Framework version.Version Minimum value of the Release DWORD .NET Framework 4.5 378389 .NET Framework 4.5.1 378675 .NET Framework 4.5.2 379893 [!INCLUDEnet_v46] 393295 [!INCLUDEnet_v461] 394254 [!INCLUDEnet_v462] 394802 .NET Framework 4.7 460798 .NET Framework 4.7.1 461308
-
Use the CLR Version Tool (Clrver.exe) to determine which versions of the common language runtime are installed on a computer.
From a Visual Studio Command Prompt, enter
clrver. This command produces output similar to the following:Versions installed on the machine: v2.0.50727 v4.0.30319For more information about using this tool, see Clrver.exe (CLR Version Tool).
-
Query the xref:System.Environment.Version%2A?displayProperty=nameWithType property to retrieve a xref:System.Version object that identifies the version of the runtime that is currently executing the code. You can use the xref:System.Version.Major%2A?displayProperty=nameWithType property to get the major release identifier (for example, "4" for version 4.0), the xref:System.Version.Minor%2A?displayProperty=nameWithType property to get the minor release identifier (for example, "0" for version 4.0), or the xref:System.Object.ToString%2A?displayProperty=nameWithType method to get the entire version string (for example, "4.0.30319.18010", as shown in the following code). This property returns a single value that reflects the version of the runtime that is currently executing the code; it does not return assembly versions or other versions of the runtime that may have been installed on the computer.
For the .NET Framework Versions 4, 4.5, 4.5.1, and 4.5.2, the xref:System.Environment.Version%2A?displayProperty=nameWithType property returns a xref:System.Version object whose string representation has the form
4.0.30319.xxxxx. For the .NET Framework 4.6 and later, it has the form4.0.30319.42000.[!IMPORTANT] For the [!INCLUDEnet_v45] and later, we do not recommend using the xref:System.Environment.Version%2A?displayProperty=nameWithType property to detect the version of the runtime. Instead, we recommend that you query the registry, as described in the To find .NET Framework versions by querying the registry in code (.NET Framework 4.5 and later) section earlier in this article.
Here's an example of querying the xref:System.Environment.Version%2A?displayProperty=nameWithType property for runtime version information:
[!code-csharpListVersions] [!code-vbListVersions]
The example produces output that's similar to the following:
Version: 4.0.30319.18010
How to: Determine Which .NET Framework Updates Are Installed
Install the .NET Framework for developers
Versions and Dependencies
