Kardock.
I have a similar issue. I need to detect the .NET 3.5 framework.
I found some information that may help.
Take a look here...
http://msdn.microsoft.com/en-us/library/bb822049.aspx
Look down to "Assembly Usage by Multiple Versions..."
An application uses the same assemblies regardless of whether it targets the
..NET Framework version 2.0, 3.0, 3.5, or the Client Profile, and regardless
of whether the assemblies have been updated on a user's computer.
This means that your "detection" mechanism needs understand this point.
Also, the application you are trying to install will possibly be run on a
..NET framework that is newer than the target one (this aggravates me a bit
because now the target runtime you tested with may not be the same as what
your customer is using).
In the above link, look at the section ".NET Framework Versions ". You
will see a table with several flavors of the .NET Framework 3.0 and when and
how they get installed. There are several Service Packs that get installed
with the .NET 3.5 and .NET 3.5 SP1.
Again, your detection mechanism needs to understand this as well.
I have found the following post to be helpful as well, but I have not tried
it yet.
http://blogs.msdn.com/astebner/archive/2004/09/18/231253.aspx Follow the
links for the sample code. It has been updated for the newer versions of the
..NET frameworks. Please note, that the Microsoft support site references
Aaron Stebner's Weblog. Look here ...
http://support.microsoft.com/kb/318785
all the way at the bottom. From what I have seen so far, the code from
Aaron Stebner site is really the most authoritative way to detect the .NET
framework versions.
Another quick way to determine if a .NET framework is installed is to simply
look in
%systemroot%\Microsoft.NET\Framework ... What directories do you see?
However, you will not be able to get all the service packs. I did notice
that if you install the SP1 version of .NET 3.5 there will be a directory
called Microsoft .NET Framework 3.5 SP1 in the v3.5 directory (under
Framework).
If you try this directory trick, you may need to watch out for multiple
"Framework" directories. On 64 bit machines I have seen
%systemroot%\Microsoft.NET\Framework and a
%systemroot%\Microsoft.NET\Framework64.
If you look in the Framework64\v3.5 you will see the "Microsoft .NET
Framework 3.5 SP1". Now do you need to determine if the operating system is
64 or 32 bit. I would say that if the Framework64 is present, then look
there for the "v3.5\Microsoft .NET Framework 3.5 SP1".
I have also seen several postings that state you could look at the mscorlib
dll and based on the dll version, you can determine what .NET framework is
installed. I believe this approach is not reliable (it may have worked in
the earlier .NET releases). Just because a .NET SP or new .NET version has
come out does not mean that the mscorlib has changed (please correct me if I
am wrong, but this is just my observation).
So to answer your question...
I am going to try
http://blogs.msdn.com/astebner/archive/2004/09/18/231253.aspx