Identify .NET Framework version

G

Guest

Is there a way to programmatically identify the .NET Framework version(s)
installed on a client PC?
My application requires 1.1 SP1 and I'd like to give a warning to the user
if they don't have it.
I found this KB,
http://support.microsoft.com/?kbid=318785&sd=msdn#XSLTH3153121122120121120120
But it suggests looking at the file versions of Mscorlib.dll, which seems a
little clunky.
Is there a class that could be queried to find this information? Is there a
better way I can make sure the user has 1.1 with SP1 installed?

Thanks,
Michael
 
P

Phil Wilson

What's the context here? Example: If you were just running a setup project
you'd use the built-in framework check for the version you need. But if you
were writing a program that checks you'd use the checks in that KB article.
 
M

Matt Dunn

Greetings Michael,

If you are attempting to perform this check at runtime, then the
following registry key indicates the service pack level for .NET 1.1:

Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework
Setup\NDP\v1.1.4322\
SubKey Name: SP
SubKey Value: 0 or 1

You can read this value using classes in the Microsoft.Win32 namespace,
see the following article for examples of how to do this:

http://msdn2.microsoft.com/en-US/library/8bf3xkta(VS.80).aspx

However, note that the user may require special privileges on their
local machine to perform this lookup.

As an alternative, performing this check as part of an installation
package may be a better solution, as the package will normally be
executed by a user/account with administratative privileges.

Cheers,
Matt
 
A

Alvin Bruney

just read the registry key HKLM software policy (memory doesn't serve me
right) but that's close enough

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
G

Guest

The context is that I have seen errors occur with my app on a PC that doesn't
have the SP1 for 1.1 installed. Installing the SP fixed the issue.

Yes, you are right in that if there is no .NET framework at all, the
application will prompt the user to install it. However, I'd like the
application to specifically check for 1.1 SP1

Michael

Phil Wilson said:
What's the context here? Example: If you were just running a setup project
you'd use the built-in framework check for the version you need. But if you
were writing a program that checks you'd use the checks in that KB article.
--
Phil Wilson [MVP Windows Installer]
----
Michael said:
Is there a way to programmatically identify the .NET Framework version(s)
installed on a client PC?
My application requires 1.1 SP1 and I'd like to give a warning to the user
if they don't have it.
I found this KB,
http://support.microsoft.com/?kbid=318785&sd=msdn#XSLTH3153121122120121120120
But it suggests looking at the file versions of Mscorlib.dll, which seems
a
little clunky.
Is there a class that could be queried to find this information? Is there
a
better way I can make sure the user has 1.1 with SP1 installed?

Thanks,
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top