How to Check Dot Net Version Installed on the PC

This code checks the dot net version installed on the PC.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
using System.Windows.Forms;
namespace BusinessLayer
class CheckVersion
public void Version(ListBox lbInstVersions)
string componentsKeyName = "SOFTWARE\\Microsoft\\Active Setup\\Installed Components",friendlyName,version;
// Find out in the registry anything under:
// HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components
// that has ".NET Framework" in the name
RegistryKey componentsKey = Registry.LocalMachine.OpenSubKey(componentsKeyName);
string[] instComps = componentsKey.GetSubKeyNames();
foreach (string instComp in instComps)
RegistryKey key = componentsKey.OpenSubKey(instComp);
friendlyName = (string)key.GetValue(null); // Gets the (Default) value from this key
if (friendlyName != null && friendlyName.IndexOf(".NET Framework") >= 0)
// Let's try to get any version information that's available
version = (string)key.GetValue("Version");
// If you want only the framework info with its SP level and not the
// other hotfix and service pack detail, uncomment this if:
//if (version != null && version.Split(',').Length >= 4)
// if(version[0].ToString()=="2")
lbInstVersions.Items.Add(friendlyName + (version != null ? (" (" + version + ")") : ""));


Related Articles

Object Serialisation in dot net

This article provides an overview of the serialization used in Microsoft .NET and the usage of the same.For example, serialization is used to save session state in ASP.NET and to copy objects to the clipboard in Windows Forms. It is also used by remoting to pass objects by value from one application domain to another.

More articles: Dot Net


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: