Wednesday, April 10, 2013

Find out .NET version


Sub Version

Microsoft.Win32.RegistryKey installed_versions = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP");
string[] version_names = installed_versions.GetSubKeyNames();
//version names start with 'v', eg, 'v3.5' which needs to be trimmed off before conversion
double Framework = Convert.ToDouble(version_names[version_names.Length - 1].Remove(0, 1), System.Globalization.CultureInfo.InvariantCulture);
int SP = Convert.ToInt32(installed_versions.OpenSubKey(version_names[version_names.Length - 1]).GetValue("SP", 0));
SP.Dump(); 


0


Main Version

System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion().Dump();

v4.0.30319

No comments:

Post a Comment