Skip to content

Instantly share code, notes, and snippets.

@EricZimmerman
Created July 22, 2015 12:43
Show Gist options
  • Save EricZimmerman/fd1e3b55b34206d3d750 to your computer and use it in GitHub Desktop.
Save EricZimmerman/fd1e3b55b34206d3d750 to your computer and use it in GitHub Desktop.
Check for .net 4.6 or greater
private static bool CheckForDotnet46()
{
using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\"))
{
int releaseKey = Convert.ToInt32(ndpKey.GetValue("Release"));
return (releaseKey >= 393295);
}
}
@EricZimmerman
Copy link
Author

Use like this:

        if (!CheckForDotnet46())
        {
            _logger.Warn(".net 4.6 not detected. Please install .net 4.6 and try again.");
            return;
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment