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.

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

Read the full how to ‘determine Which .NET Framework Versions Are Installed’ on docs.microsoft.com: How to: Determine Which .NET Framework Versions Are Installed

In PowerShell use the Get-ItemProperty cmdlet to get the installed .NET version:

(Get-ItemProperty "HKLM:Software\Microsoft\NET Framework Setup\NDP\v4\Full").Version

Check for a DWORD value named Release. The existence of the Release DWORD indicates that the .NET Framework 4.5 or newer has been installed on that computer.

(Get-ItemProperty "HKLM:Software\Microsoft\NET Framework Setup\NDP\v4\Full").Release
.NET Framework versionValue of the Release DWORD
.NET Framework 4.5All Windows operating systems: 378389
.NET Framework 4.5.1On Windows 8.1 and Windows Server 2012 R2: 378675
On all other Windows operating systems: 378758
.NET Framework 4.5.2All Windows operating systems: 379893
.NET Framework 4.6On Windows 10: 393295
On all other Windows operating systems: 393297
.NET Framework 4.6.1On Windows 10 November Update systems: 394254
On all other Windows operating systems (including Windows 10): 394271
.NET Framework 4.6.2On Windows 10 Anniversary Update and Windows Server 2016: 394802
On all other Windows operating systems (including other Windows 10 operating systems): 394806
.NET Framework 4.7On Windows 10 Creators Update: 460798
On all other Windows operating systems (including other Windows 10 operating systems): 460805
.NET Framework 4.7.1On Windows 10 Fall Creators Update and Windows Server, version 1709: 461308
On all other Windows operating systems (including other Windows 10 operating systems): 461310
.NET Framework 4.7.2On Windows 10 April 2018 Update and Windows Server, version 1803: 461808
On all Windows operating systems other than Windows 10 April 2018 Update and Windows Server, version 1803: 461814
.NET Framework 4.8On Windows 10 May 2019 Update: 528040
On all others Windows operating systems (including other Windows 10 operating systems): 528049
This may interest you:   Failed Request Tracing error LOG FILE MAX SIZE TRUNCATE

(table copied from the earlier mentioned docs.microsoft.com article)

About .NET Framework versions: Did you know you can use the /clr parameter of AppCmd to target multiple ASP.NET CLR versions with AppCmd? CLR stands for Common Language Runtime. Pretty neat heh? 🙂

Determine if .NET Core is installed, and its versions

If you want to know whether .NET Core is installed and, if yes, the available versions, you can use PowerShell. On Stack Overflow, Andriy Tolstoy lists a way to list the .NET Core runtimes available, and the SDK’s:

(dir (Get-Command dotnet).Path.Replace('dotnet.exe', 'shared\Microsoft.NETCore.App')).Name
(dir (Get-Command dotnet).Path.Replace('dotnet.exe', 'sdk')).Name

On Microsoft’s Technet Script Center gallery, you may find an additional How to determine ASP.NET Core installation on a Windows Server by PowerShell recipe contributed by OneScript Team:

$DotNETCoreUpdatesPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Updates\.NET Core" 
$DotNetCoreItems = Get-Item -ErrorAction Stop -Path $DotNETCoreUpdatesPath 
$NotInstalled = $True 
$DotNetCoreItems.GetSubKeyNames() | Where { $_ -Match "Microsoft .NET Core.*Windows Server Hosting" } | ForEach-Object { 
    $NotInstalled = $False 
    Write-Host "The host has installed $_" 
} 
If ($NotInstalled) { 
    Write-Host "Can not find ASP.NET Core installed on the host" 
}

buy me a coffee
Buy Me A Coffee