Saturday, 12 January 2013

how to find dot net version installed

how to find dot net version installed


Step 1)  Add NameSpace Microsoft.Win32


Step 2)  How to find dot net version installed

void Get_dotnet_version()
        {
        Console.WriteLine();
        Console.WriteLine();
        try
        {
        RegistryKey key = Registry.LocalMachine;
        //HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework
        RegistryKey dotnetkey = key.OpenSubKey(@"SOFTWARE\Microsoft\.NETFramework\", RegistryKeyPermissionCheck.Default,System.Security.AccessControl.RegistryRights.FullControl);
        System.Text.StringBuilder sb = new StringBuilder();
        foreach (String NameValue in dotnetkey.GetSubKeyNames())
        {
        //if("DbgManagedDebugger"!=NameValue)
        Console.WriteLine("{0}", NameValue);//, dotnetkey.GetValue(NameValue).ToString().Replace("\""," ").Replace("%"," "));
        //sb.Append(NameValue + " ") ;//+ dotnetkey.GetValue(NameValue).ToString());
        //sb.AppendLine();
        }
        }
        catch (Exception ex)
        {
        Console.WriteLine(ex.Message);
        }


Output

AssemblyFolders
Fusion
NGen
NGenQueue
Policy
Security
v1.0
v2.0.50727
v3.0
v3.5
v4.0.30319
v4.5.50709
Windows Presentation Foundation

No comments:

Post a Comment