Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to check .net framework version

In this article, I will explain what is .net framework used for and how to check .net framework version in different ways. You can install and run multiple versions of the .NET framework on your machine. When you develop or deploy your app, you might need to know which .NET Framework versions are installed on the user’s computer.

  • Keep reading on Hospital Management System Project ASP.NET, School Management System .Net Project

What is the .NET Framework?

.NET Framework is a software development framework for building and running applications on the Windows platform. The first version of the .Net framework was released in the year 2002. You need .NET Framework installed in order to run applications on Windows that were created using .NET Framework.

The two major components of the .NET Framework are the Common Language Runtime (CLR) and the .NET Framework Class Library. The CLR is the execution engine that handles running applications. The Class Library provides a set of APIs and types for common functionality. See below the Architecture of .Net Framework:-

Check .net framework version installed

The registry contains a list of the .NET Framework versions installed on a machine. You can either use the Registry Editor to view the registry or query it with code:

There are 2 different ways to find what .net framework do I have.

  • Using the Registry Editor to find .NET Framework versions.
  • Use code to query the registry for .NET Framework versions.

Find newer .NET Framework versions (4.5 and later)

We can use Registry Editor to find version information in the registry, or you can query the registry programmatically.

Use Registry Editor

  • From the Start menu, choose Run, enter regedit, and then select OK.
  • In the Registry Editor, open the following subkey: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full. If the Full subkey isn’t present, then you don’t have the .NET Framework 4.5 or later installed.
  • Check for a DWORD entry named Release. If it exists, then you have .NET Framework 4.5 or later installed. Its value is a release key that corresponds to a particular version of the .NET Framework. In the following figure, for example, the value of the Release entry is 378389, which is the release key for .NET Framework 4.5.

The following table lists the value of the Release DWORD on individual operating systems for .NET Framework 4.5 and later versions.

.NET Framework version Value of the Release DWORD
.NET Framework 4.5 All Windows operating systems: 378389
.NET Framework 4.5.1 On Windows 8.1 and Windows Server 2012 R2: 378675

On all other Windows operating systems: 378758

.NET Framework 4.5.2 All Windows operating systems: 379893
.NET Framework 4.6 On Windows 10: 393295

On all other Windows operating systems: 393297

.NET Framework 4.6.1 On Windows 10 November Update systems: 394254

On all other Windows operating systems (including Windows 10): 394271

.NET Framework 4.6.2 On 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.7 On Windows 10 Creators Update: 460798

On all other Windows operating systems (including other Windows 10 operating systems): 460805

.NET Framework 4.7.1 On 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.2 On 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.8 On Windows 10 May 2019 Update and Windows 10 November 2019 Update: 528040

On all other Windows operating systems (including other Windows 10 operating systems): 528049

Query the registry using code in C#

The following example checks the value of the Release entry in the registry to find the .NET Framework 4.5 and later versions that are installed:

using System;
using Microsoft.Win32;

public class GetDotNetVersion
{
   public static void Main()
   {
      Get45PlusFromRegistry();
   }

   private static void Get45PlusFromRegistry()
   {
      const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";

      using (var ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey))
      {
        if (ndpKey != null && ndpKey.GetValue("Release") != null) {
            Console.WriteLine($".NET Framework Version: {CheckFor45PlusVersion((int) ndpKey.GetValue("Release"))}");
        }
         else {
            Console.WriteLine(".NET Framework Version 4.5 or later is not detected.");
         } 
      }
   
      // Checking the version using >= enables forward compatibility.
      string CheckFor45PlusVersion(int releaseKey)
      {
         if (releaseKey >= 528040)
            return "4.8 or later";
         if (releaseKey >= 461808)
            return "4.7.2";
         if (releaseKey >= 461308)
            return "4.7.1";
         if (releaseKey >= 460798)
            return "4.7";
         if (releaseKey >= 394802)
            return "4.6.2";
         if (releaseKey >= 394254)
            return "4.6.1";      
         if (releaseKey >= 393295)
            return "4.6";      
         if (releaseKey >= 379893)
            return "4.5.2";      
         if (releaseKey >= 378675)
            return "4.5.1";      
         if (releaseKey >= 378389)
            return "4.5";      
         // This code should never execute. A non-null release key should mean
         // that 4.5 or later is installed.
         return "No 4.5 or later version detected";
      }
   }
}   
// This example displays output like the following:
//       .NET Framework Version: 4.6.1

MSDN Reference

Conclusion

I hope you liked this article on how to check .net framework version. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

The post How to check .net framework version appeared first on DotNetTec.



This post first appeared on Asp Dot Net Tricks And Tips, Dot Net Coding Tips, Google Maps API Developer, please read the originial post: here

Share the post

How to check .net framework version

×

Subscribe to Asp Dot Net Tricks And Tips, Dot Net Coding Tips, Google Maps Api Developer

Get updates delivered right to your inbox!

Thank you for your subscription

×