.NET - How to determine the installed CLR version

(4 different techniques)

Is it CLR version or Framework version? What's the difference?


The CLR is the .NET Runtime.
The Framework is the .NET Class Library.


CLR version numbers are of the form:

    1.0 | 1.1 | 2.0 | 4.0

Framework version numbers are of the form:

    1.0 | 1.1 | 2.0 | 3.0 | 3.5 | 4 | 4.5 | 4.5.1 | 4.5.2 | 4.6 | 4.6.1 | 4.6.2 | 4.7


Typically, there is a 1-1 correspondence between a Framework version and a CLR version. E.g. Framework 4.x, is usually built on CLR 4.x.
There are exceptions. Framework versions 3.0 and 3.5 were built on CLR version 2.0.

1
If you have Visual Studio installed, you can use clrver.exe.
  c:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7 Tools\x64>clrver
 
  Microsoft (R) .NET CLR Version Tool  Version 4.7.2046.0
  Copyright (c) Microsoft Corporation.  All rights reserved.
  
  Versions installed on the machine:
  v2.0.50727
  v4.0.30319
  
2
You can use Windows Powershell to query the Powershell Version table $PSVersionTable:
  PS C:\Users\Zuga> $ver = $PSVersionTable.CLRVersion
  PS C:\Users\Zuga> $ver
  Major  Minor  Build  Revision
  -----  -----  -----  --------
  4      0      30319  42000
3
You can use Windows Powershell to query the .NET Property Environment.Version.
  PS C:\Users\Zuga> $ver = ([System.Environment]::Version)
  PS C:\Users\Zuga> $ver
  Major  Minor  Build  Revision
  -----  -----  -----  --------
  4      0      30319  42000
4
You can write a console application using C# to query the property Environment.Version.

  class Program
  {
      static void Main(string[] args)
      {
          Console.WriteLine($"Version: {Environment.Version}");
      }
  }

Program output:

  Version: 4.0.30319.42000  

Ads by Google

Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath