Walker News

How To Check .Net Framework Version Installed

Microsoft .Net 3.5 framework is in RTM version since Nov 2007. While not every Windows machines require .Net framework to run, but sooner or later you may find some programs failed because of no such framework installed or otherwise the latest .Net 3.5 framework is not found.

In this case, you might wonder what .Net framework version you have or do you have the so-called latest .Net 3.5 framework?
UPDATE: All screenshots have been updated on 31-May-2011.

OK, general end users can use either one of these ways to check the .Net framework version:
  • Query the User Agent String of Internet Explorer web browser. This is the easier way, I think, as every Windows bundled with IE! Although you need to remember this simple, one line JavaScript:
    javascript:alert(navigator.userAgent)
    

    Copy and paste that line of JavaScript code to IE Address bar and press ENTER key, you will see a pop-up dialog box with similar content as this:

    Using IE User Agent String to check .Net framework version installed.

    As shown, the IE 7 User Agent String shows my Windows Vista (Windows NT 6.0) has installed .Net 2.0 (.Net CLR 2.0.50727), .Net 3.0 (.Net CLR 3.0.04506) as well as the latest .Net 3.5 framework (.Net CLR 3.5.21022).

    Please take note that that JavaScript code can be used in Firefox or Opera web browser to query their User Agent String too (but only the IE will report .Net framework version in its User Agent String).
     
  • Navigate to this Windows Registry path:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP

    The major version number of each .Net framework releases installed can be found at this Registry path. Click the major version number key and there is a string value called “version” on the right-pane that reports the full version number of that .Net framework:
     
    Windows Registry that reports .Net version installed in Windows.
     
  • Navigate to the Registry path that keeps the IE User Agent String:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform
    

    If you think this Registry key path is easier to remember than the shorter, one-line JavaScript code that query the User Agent String, then this could be your answer.
     
  • For those who have installed the latest .Net framework SDK, any of the .Net compilers report the .Net framework version at Command Prompt window as well.
     
    For example, enter this C# command line compiler csc at Command Prompt window shows a similar header message as this:

    .Net SDK C# command line compiler shows the .Net framework version installed.

If you’re programmer who is going to develop a simple .Net framework version verifier, here are two options, but only second option seems to be better:
  • Environment.Version property of .Net framework. For example, this simple C# source code can be compiled to a .Net console program that shows .Net framework version installed:
    using System;
    
    class Version
    {
      public static void Main()
      {
        Console.WriteLine();
        Console.WriteLine(".Net Framework Version {0}",
           Environment.Version.ToString());
      }
    }
    

    You don’t have to install Visual Studio except the .Net framework SDK (which package all the .Net command line compilers, including the C# compiler). Thus, to compile the C# code in a source file called sample.cs with C# command line compiler, just enter this at Command Prompt:
    csc sample.cs
    
  • Limitation of Environment.Version property – only one of the multiple .Net framework versions installed will be reported. I.e. if you’ve .Net 2.0, .Net 3.0 and .Net 3.5 version installed, Environment.Version reports only .Net 2.0 framework.
     
    To overcome this problem, Aaron Stebner’s .Net version checker source code is better choice, where the programming approach is to query the Windows Registry keys and also call the mscoree.dll exported APIs to report the presence of all .NET Framework versions.

    Aaron Stebner .Net version checker source code

    Download the .Net version checker source code and compile the code with Visual Studio 2005 or Visual C++ 2005 Express edition, with the present of .Net framework 2.0 SDK or mscoree.h from that version of the SDK.

P/S: To direct download the latest .Net framework 3.5 full package (197 MB), you may find it at Microsoft Download Center, or just click here to direct download from genuine Microsoft server.

Custom Search

  1. shazif 10-09-08@19:08

    Hi,
    This is shazif,
    can any one tell me how to check programatically the .Net installation using C# please….

  2. Regmee 17-10-08@01:48

    For C# , Environment.Version gave me 2.0.50727.1434 though I have 3.5 installed and my express VS 2008 compiles my application as a 3.5 .NET application.

    I think that is the reason why the Application asks for 2.0 .NET install when getting it installed in a system without any .NET framework.

    Moreover it crashes in a system that has 2.0 but does not have 3.5. I would like to know how I can fix this.

    I wanted to test for 3.5 .NET installation with the Environment.Version check and exit application if system has no 3.5 .NET. But that doesn’t seem to be possible either.

    -Regmee

  3. Marios Koumides 19-10-08@22:04

    The below shows all the .NET Framework versions installed in a box.

    class Program
        {
            const string  regLocation="SOFTWARE\\Microsoft\\NET Framework Setup\\NDP";
            static void Main(string[] args)
            {
    
                Console.WriteLine(".NET Framework versions installed");
                Console.WriteLine("---------------------------------");
                Console.WriteLine();
                RegistryKey masterKey = Registry.LocalMachine.OpenSubKey(regLocation);
                RegistryKey tempKey;
    
    
                if (masterKey == null)
                {
                    Console.WriteLine("Null Key!");
                }
                else
                {
                    string[] SubKeyNames = masterKey.GetSubKeyNames();
                    for (int i = 0; i < SubKeyNames.Length; i++)
                    {
                        tempKey = Registry.LocalMachine.OpenSubKey(regLocation + "\\"  + SubKeyNames[i]);
                        Console.Write(SubKeyNames[i]);
                        Console.WriteLine("\tVersion = {0}", tempKey.GetValue("Version"));
                    }
                }
               
                Console.ReadKey();
            }
        } //end class
    
  4. regmee 20-10-08@00:28

    Hi Marios,

    I got to that point. But that won’t solve my problem. I won’t be able to execute that piece of code written in .NET 3.5 in a machine that has no .NET framework, or just has .NET 2.0 installed.

    If you go back to my previous comment, my problem is, for my 3.5 application , a system without .NET is asking me to install 2.0 and in a system that already has 2.0 – the application crashes.

    I won’t be able to create an installer that could possibly help me check that because my application is an Skype add-on and has to be published with Skype Publishing Studios that takes my binaries and makes a .sparc installer.

    any thought ??

    -regmee

  5. Walker 20-10-08@01:21

    Hi Marios Koumides, thank you for sharing this block of code.

    To readers:

    If you find Aaron Stebner’s .Net version checker source code (C++.net) is “too complex”, Marios’s C# code could be your choice.

    Aaron Stebner vs Marios Koumides:

    Aaron Stebner (cf “Limitation of Environment.Version property” section at above)

    1) Written in C++.net
    2) Reading both Registry key value and mscoree.dll exported APIs to report the presence of all .NET Framework versions.

    Marios Koumides

    1) Written in C#
    2) Reading only Registry key value

    Notes to Marios Koumides’s source code:

    1) You need to insert two namespaces before class program:

    using System;
    using Microsoft.Win32;
    

    2) If you copy and paste the block of code, you might need to replace most of the typographic double-quotation marks to typewriter double-quotation marks, i.e. change to "

  6. dunxd 01-12-08@23:21

    Microsoft have an alternative method:
    http://support.microsoft.com/kb/318785

  7. Yair 04-06-09@06:15

    Yep, saves a lot of time !
    Many thanks.

    Just a small comment in windows server the CSC.exe is located in

    C:\WINDOWS\Microsoft.NET\Framework\ ( VER that is installed )
    
  8. Yair Tendler 04-06-09@06:15

    Many thanks.

    Just a small comment in windows server the CSC.exe is located in

    C:\WINDOWS\Microsoft.NET\Framework\ ( VER that is installed ) 
    

    Upgrades will be installed in program files.

  9. Tbone 17-06-10@22:50

    Note about IE method when using javascript:alert(navigator.userAgent): Javascript doesn’t execute if IE is displaying blank page (about:blank in address bar). Open any web page, including other about pages like about:Tabs.

  10. Walker 18-06-10@16:40

    @Tbone, thanks heaps!

  11. antony 06-09-10@13:06

    Hi,

    I have installed .net framework 4.0 in my new machine in E:/ drive. But in All Programs -> Microsoft visual studio is not available.

  12. Rollout 14-09-10@23:39

    Thank you for providing the options above to help me discover the current version of the .net framework I have installed. I have been searching for a while for a site that provided just this information.

  13. Happy 15-09-10@18:42

    Excellent Tip!

  14. Sachin 19-10-10@13:45

    excellent..That is what i was looking for :)

    Thanks
    Sachin

  15. dpminusa 30-11-10@17:30

    Great Method.

    You may want to make a small adjustment to account for the v4 subkey where the Version is. Place it above the exisitng if , not nested.

    if (SubKeyNames[i] == "v4") // Version is in subkey.
         {
             tempKey = Registry.LocalMachine.OpenSubKey(regLocation + "\\" + SubKeyNames[i] + "\\Full");
         } 
    

    Thanks Marios. :-)

  16. 1zzz 17-12-10@10:41

    Hi,

    I’m currently working my installer script using izpack.
    Can you help me on how to check if .Net Framework was installed.

    thanks,
    1zzz

  17. Edgar 28-12-10@19:44

    Excelent Help. Thaks for share.

  18. Margaret 05-01-13@01:22

    This is very helpful. Solved my issue without having to learn to program.
    Thanks!!

2014  •  Privacy Policy