Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Way to determine framework version without Registry

I've searching a long time, but i couldn't find answer. Is there any way to determine framework and service pack .NET installed on PC, without access to registry in C#? I can use registry keys, but i have to do this without access to registry. I read something about directories in C:\Windows\Microsoft .NET, but there, I only found framework version, nothing about SP. But I need framework and Service Pack. Can somebody help me?

Regards, Greg

like image 556
ogrod87 Avatar asked Aug 01 '11 14:08

ogrod87


2 Answers

string clrVersion = System.Environment.Version.ToString();
string dotNetVersion = Assembly
                      .GetExecutingAssembly()
                      .GetReferencedAssemblies()
                      .Where(x => x.Name == "mscorlib").First().Version.ToString();
like image 117
sll Avatar answered Oct 14 '22 17:10

sll


you could use WMI to get a list of all the installed software filtering the result to achieve your goal

 public static class MyClass
    {
        public static void Main()
        {
            ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_Product");
            foreach (ManagementObject mo in mos.Get())
            {
                Console.WriteLine(mo["Name"]);
            }


        }
    }
like image 42
Massimiliano Peluso Avatar answered Oct 14 '22 16:10

Massimiliano Peluso