Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Way To Determine If .NET 3.5 Is Installed

I need to programatically determine whether .NET 3.5 is installed. I thought it would be easy:

<% Response.Write(Environment.Version.ToString()); %>

Which returns "2.0.50727.1434" so no such luck...

In my research I have that there are some rather obscure registry keys I can look at but I'm not sure if that is the route to go. Does anyone have any suggestions?

like image 371
sestocker Avatar asked Aug 19 '08 13:08

sestocker


People also ask

How can I tell what version of .NET is being used?

Open Start. Search for Command Prompt, right-click the top result, and select the Run as administrator option. Type the following command to determine the version of . NET installed and press Enter: reg query "HKLM\SOFTWARE\Microsoft\Net Framework Setup\NDP" /s To make sure that version 4.

Is .NET 3.5 installed by default?

NET Framework 3.5 is not included by default in Windows 10, Windows Server 2016, and later operating systems but you can download and deploy it for application compatibility.


1 Answers

You could try:

static bool HasNet35()
{
    try
    {
        AppDomain.CurrentDomain.Load(
            "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
        return true;
    }
    catch
    {
        return false;
    }
}

@Nick: Good question, I'll try it in a bit.

Kev

like image 193
Kev Avatar answered Oct 14 '22 06:10

Kev