Click here to Skip to main content
Email Password   helpLost your password?

Introduction

Developers are increasingly faced with the possibility of multiple .NET Framework versions being installed on the same machine. The .NET architecture was designed to allow multiple versions of a component to be installed and run at the same time on a single system, and this side-by-side deployment extends to the .NET Framework itself. By allowing multiple versions of the .NET Framework to be installed on the same computer, applications built with version 1.0 of the .NET Framework can run using the newer versions, or continue running with the earlier version. By default, client-side applications will use the version of the .NET Framework with which they were built, even when a newer version is available on the client.

There are situations, however, where it becomes important, or at least interesting, to know which versions of the .NET Framework are installed. Typically, this is done during installation, and the best way to do this is using unmanaged C++. Remember, you can only run managed code if a version of the .NET Framework is already installed, so this class is not guaranteed to work as part of an installation process. Aaron Stebner has a great set of blog posts [^] (including sample code) that shows how to do this in C++, and you can also check out this article [^].

While C++ may be the best way to do this, there are still times when this same functionality is needed in managed code. After searching both Google and CodeProject, I was unable to find a satisfactory solution in managed code. As a result, I decided to port Aaron's code to C#. This code uses Generics, so it is only compatible with version 2.0 or later of the .NET Framework.

Background

The correct way to determine if a specific version of the .NET Framework is installed is to look in the Registry. Aaron and a few readers of this article have pointed out that this solution, while the recommended way, is not 100% accurate in all situations. There are occasions when the Registry keys are orphaned, such as OS reinstalls. The solution presented by Aaron uses a technique by Junfeng Zhang [^] which loads mscoree.dll and uses some of its API functions to query for the presence of specific versions of the .NET Framework. The problem with this approach is that it only works from unmanaged code.

I took a slightly different approach, which more closely follows how the .NET Framework 3.5 setup checks for its prerequisites [^]. This approach looks for the presence of mscorwks.dll and, if found, verifies that the version number of the file is greater than or equal to the requested .NET Framework version, in addition to verifying that the Registry value is greater than or equal to the requested .NET Framework version. Consequently, if the file isn't found, I simply test the Registry value.

Using the code

Each major release of the .NET Framework has changed the Registry location and, in some cases, the keys and value names to look for in the Registry. In order to consolidate checking all of the various Registry keys and help isolate changes for future versions of the .NET Framework, the FrameworkVersionDetection class was created. This class exposes the following public methods and properties:

As you can see, all of these functions use either the FrameworkVersion or the WindowsFoundationLibrary enumeration. These enumerations have the following definition:

/// <summary>/// Specifies the .NET Framework versions
///// </summary>
public enum FrameworkVersion
{
  /// <summary>
  /// .NET Framework 1.0
  /// </summary>
  Fx10,

  /// <summary>
  /// .NET Framework 1.1
  /// </summary>
  Fx11,

  /// <summary>
  /// .NET Framework 2.0
  /// </summary>
  Fx20,

  /// <summary>
  /// .NET Framework 3.0
  /// </summary>
  Fx30,

  /// <summary>
  /// .NET Framework 3.5
  /// </summary>
  Fx35,
}

/// <summary>
/// Specifies the .NET 3.0 Windows Foundation Library
/// </summary>
public enum WindowsFoundationLibrary
{
  /// <summary>
  /// Windows Communication Foundation
  /// </summary>
  WCF,

  /// <summary>
  /// Windows Presentation Foundation
  /// </summary>
  WPF,

  /// <summary>
  /// Windows Workflow Foundation
  /// </summary>
  WF,

  /// <summary>
  /// Windows CardSpace
  /// </summary>
  CardSpace,
}

A complete example in C# looks like this:

bool fx10Installed = FrameworkVersionDetection.IsInstalled(FrameworkVersion.Fx10);
bool fx11Installed = FrameworkVersionDetection.IsInstalled(FrameworkVersion.Fx11);
bool fx20Installed = FrameworkVersionDetection.IsInstalled(FrameworkVersion.Fx20);
bool fx30Installed = FrameworkVersionDetection.IsInstalled(FrameworkVersion.Fx30);
bool fx35Installed = FrameworkVersionDetection.IsInstalled(FrameworkVersion.Fx35);

Console.WriteLine(".NET Framework 1.0 installed? {0}", fx10Installed);
if (fx10Installed)
{
   Console.WriteLine(".NET Framework 1.0 Exact Version: {0}",
      FrameworkVersionDetection.GetExactVersion(FrameworkVersion.Fx10));
   Console.WriteLine(".NET Framework 1.0 Service Pack: {0}",
      FrameworkVersionDetection.GetServicePackLevel(FrameworkVersion.Fx10));
}
Console.WriteLine();

Console.WriteLine(".NET Framework 1.1 installed? {0}", fx11Installed);
if (fx11Installed)
{
   Console.WriteLine(".NET Framework 1.1 Exact Version: {0}",
     FrameworkVersionDetection.GetExactVersion(FrameworkVersion.Fx11));
   Console.WriteLine(".NET Framework 1.1 Service Pack: {0}",
     FrameworkVersionDetection.GetServicePackLevel(FrameworkVersion.Fx11));
}
Console.WriteLine();

Console.WriteLine(".NET Framework 2.0 installed? {0}", fx20Installed);
if (fx20Installed)
{
   Console.WriteLine(".NET Framework 2.0 Exact Version: {0}",
     FrameworkVersionDetection.GetExactVersion(FrameworkVersion.Fx20));
   Console.WriteLine(".NET Framework 2.0 Service Pack: {0}",
     FrameworkVersionDetection.GetServicePackLevel(FrameworkVersion.Fx20));
}
Console.WriteLine();

Console.WriteLine(".NET Framework 3.0 installed? {0}", fx30Installed);
if (fx30Installed)
{
   Console.WriteLine(".NET Framework 3.0 Exact Version: {0}",
     FrameworkVersionDetection.GetExactVersion(FrameworkVersion.Fx30));
   Console.WriteLine(".NET Framework 3.0 Service Pack: {0}",
     FrameworkVersionDetection.GetServicePackLevel(FrameworkVersion.Fx30));

   bool fx30PlusWCFInstalled = 
        FrameworkVersionDetection.IsInstalled(WindowsFoundationLibrary.WCF);
   bool fx30PlusWPFInstalled = 
        FrameworkVersionDetection.IsInstalled(WindowsFoundationLibrary.WPF);
   bool fx30PlusWFInstalled = 
        FrameworkVersionDetection.IsInstalled(WindowsFoundationLibrary.WF);
   bool fx30PlusCardSpacesInstalled =
      FrameworkVersionDetection.IsInstalled(WindowsFoundationLibrary.CardSpace);

   Console.WriteLine();

   Console.WriteLine("Windows Communication Foundation installed? {0}", 
                     fx30PlusWCFInstalled);
   if (fx30PlusWCFInstalled)
   {
     Console.WriteLine("Windows Communication Foundation Exact Version: {0}",
       FrameworkVersionDetection.GetExactVersion(WindowsFoundationLibrary.WCF));
   }
   Console.WriteLine();

   Console.WriteLine("Windows Presentation Foundation installed? {0}", 
                     fx30PlusWPFInstalled);
   if (fx30PlusWPFInstalled)
   {
     Console.WriteLine("Windows Presentation Foundation Exact Version: {0}",
       FrameworkVersionDetection.GetExactVersion(WindowsFoundationLibrary.WPF));
   }
   Console.WriteLine();

   Console.WriteLine("Windows Workflow Foundation installed? {0}", 
                     fx30PlusWFInstalled);
   if (fx30PlusWFInstalled)
   {
     Console.WriteLine("Windows Workflow Foundation Exact Version: {0}",
       FrameworkVersionDetection.GetExactVersion(WindowsFoundationLibrary.WF));
   }
   Console.WriteLine();

   Console.WriteLine("Windows CardSpaces installed? {0}", 
                     fx30PlusCardSpacesInstalled);
   if (fx30PlusCardSpacesInstalled)
   {
     Console.WriteLine("Windows CardSpaces Exact Version: {0}",
       FrameworkVersionDetection.GetExactVersion(WindowsFoundationLibrary.CardSpace));
   }
   Console.WriteLine();
}
Console.WriteLine();

Console.WriteLine(".NET Framework 3.5 installed? {0}", fx35Installed);
if (fx35Installed)
{
   Console.WriteLine(".NET Framework 3.5 Exact Version: {0}",
     FrameworkVersionDetection.GetExactVersion(FrameworkVersion.Fx35));
   Console.WriteLine(".NET Framework 3.5 Service Pack: {0}",
     FrameworkVersionDetection.GetServicePackLevel(FrameworkVersion.Fx35));
}
 
foreach (Version fxVersion in FrameworkVersionDetection.InstalledFrameworkVersions)
{
   Console.WriteLine(fxVersion .ToString());
}

Registry keys

The Registry keys used to determine if a particular version of the .NET Framework is installed are:

Framework Version Registry Key
1.0 HKLM\Software\Microsoft\.NETFramework\Policy\v1.0\3705
1.1 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322\Install
2.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Install
3.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\InstallSuccess
3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\Install

For the .NET Framework v1.0, this is a string value; all of the other versions use a DWORD value which, if present and set to 1, indicates that version of the Framework is installed. For .NET 3.0, it is important to also verify that .NET 2.0 is also installed, and for .NET 3.5, you should verify that both .NET 2.0 and 3.0 are also installed. In order to determine the Service Pack level, the following Registry keys are used:

Framework Version Registry Key

1.0

(Windows Media Center

or

Windows XP Tablet Edition)

HKLM\Software\Microsoft\Active Setup\Installed Components\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}\Version
1.0 HKLM\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}\Version
1.1 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322\SP
2.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\SP
3.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\SP
3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\SP

As you can see, in order to determine the Service Pack level for the .NET Framework v1.0, it is necessary to know if the Operating System is Windows Media Center or Windows XP Tablet Edition before looking in the Registry. To complicate things even more, for .NET 1.0, the Registry value at either of these keys is a string value of the format #,#,####,#. The last # is the Service Pack level. For all of the other versions, this is a DWORD value indicating the Service Pack level.

Finally, to determine the exact version number of the Framework, we look at the following Registry keys:

Framework Version Registry Key

1.0

(Windows Media Center

or

Windows XP Tablet Edition)

HKLM\Software\Microsoft\Active Setup\Installed Components\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}\Version
1.0 HKLM\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}\Version
1.1 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322
2.0

HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Version

- or -

HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Increment

3.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Version
3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\Version

Again, for .NET 1.0, it is necessary to know if the Operating System is Windows Media Center or Windows XP Tablet Edition before looking in the Registry, and the Registry value at either of these keys is a string value of the format #,#,####,#. The #,#,#### portion of the string is the Framework version.

For .NET 1.1, we use the name of the Registry key itself, which represents the version number, and for .NET 2.0, there are two different methods for determining the exact version number. If .NET 2.0 Original Release (RTM) is installed, then the version number is derived from the key name itself and the Increment Registry value (which is a string value representing the fourth part of the version number). Service Pack 1 for the .NET Framework 2.0 added the Version Registry value.

.NET Framework v3.0 Foundation libraries

In order to detect if any of the Foundation libraries are installed, you need to use the InstallSuccess Registry value from following rRegistry keys:

Foundation Library Registry Key
Windows Communication Foundation HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\Windows Communication Foundation
Windows Presentation Foundation HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\Windows Presentation Foundation
Windows Workflow Foundation HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\Windows Workflow Foundation

As is the case for the .NET Framework 3.0 itself, this is a DWORD value which, if present and set to 1, indicates that the Foundation library is installed. There have not been any service packs released specifically for the Foundation libraries, so at this time, there are no Registry keys to evaluate.

Determining the exact version number for any of the Foundation libraries uses the following Registry keys:

Foundation Library Registry Key
Windows Communication Foundation HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\Windows Communication Foundation\Version
Windows Presentation Foundation HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\Windows Presentation Foundation\Version
Windows Workflow Foundation HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\Windows Workflow Foundation\FileVersion

Determining this information for Windows CardSpace is not as straightforward. The Registry can still be used to determine if Windows CardSpace is installed:

HKLM\System\CurrentControlSet\Services\idsvc\ImagePath

In order to determine the exact version, we must interrogate the file using the FileVersionInfo class and the value returned from the Registry key.

Points of interest

The public methods are simply wrappers that determine which private function should be called. These private functions, in turn, query the appropriate Registry keys and process the result. However, the real work is done in the GetRegistryValue<T> function. This is a generic function that returns a bool value indicating if the requested Registry key was found and an out parameter that contains the value. By making this a generic function, I was able to simply encapsulate all of the Registry access in a single function, and was able to more closely match the original C++ code provided by Aaron. The GetRegistryValue<T> function is defined as:

private static bool GetRegistryValue<T>(RegistryHive hive, string key, string value,
        RegistryValueKind kind, out T data)
{
  bool success = false;
  data = default(T);

  using (RegistryKey baseKey = RegistryKey.OpenRemoteBaseKey(hive, String.Empty))
  {
     if (baseKey != null)
     {
        using (RegistryKey registryKey = baseKey.OpenSubKey(key,
          RegistryKeyPermissionCheck.ReadSubTree))
        {
           if (registryKey != null)
           {
              // If the key was opened, try to retrieve the value.
              RegistryValueKind kindFound = registryKey.GetValueKind(value);
              if (kindFound == kind)
              {
                 object regValue = registryKey.GetValue(value, null);
                 if (regValue != null)
                 {
                    data = (T)Convert.ChangeType(regValue, typeof(T),
                      CultureInfo.InvariantCulture);
                    success = true;
                 }
              }
           }
        }
     }
  }
  return success;
}

It is important to note that if the user does not have the appropriate permissions to access the Registry, this function will throw an exception that will bubble up to the original caller. This was intentionally done to allow the caller the ability to take different actions based on the exception thrown.

Future considerations

I have not tested this code on any of the .NET Compact Framework versions, or determined how to detect the installed Compact Framework versions. If someone wants to do this investigation and let me know their findings, I will update the code accordingly.

If someone wants to test this on Windows XP 64-bit and Windows Vista 64-bit systems, let me know if it runs properly, and if not, what the errors are, and I will correct them.

Revision history

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralRun this against another machine
DimondWolfe
12:06 16 Oct '09  
Do you think it's possible to run this against another machine on my network? I've got a couple of hundred machines that I need to check to see if they have 3.5 SP1 installed. Would it be possible to point this app at a remote machine, do you think?

You know what ol' Jack Burton says at a time like this...

GeneralRe: Run this against another machine
scot.belshaw
16:09 18 Oct '09  
try this one...
XFxDetect - A utility to detect which versions of .Net are installed[^]
it works on remote machines
GeneralVery practical article!
DrABELL
17:25 16 Sep '09  
Hello Scott:

You are just right!

.NET side-by-side execution initially came as a great relief from former "DLL-h..ll", but... well, the rest is well presented in your article Smile

Great job! Kudos to the author and 5*.

My best,

Alex

PS. ...that's mostly why I like web apps more than their win counterparts Smile
General4.0 framework?
nmerali
5:54 26 Aug '09  
Any update about the 4.0 Framework check?

Thanks,
Nadin
GeneralDifferent Info on Vista and XP
vinodonly
0:08 11 Jul '09  
Thanks for posting this useful article...

I tested your library on Vista and XP with all updates installed till now, but it is returning different version information.

If you need more details then kindly send me msg and I will provide the same. ( I have used contact form on your blog also to post this same msg)

I wanted to request if there is a possibility of fixing this issue.

Thanks in advance..
GeneralRe: Different Info on Vista and XP
Scott Dorman
4:31 11 Jul '09  
What issues are you running in to? This was developed on an XP machine that was then upgraded to Vista and I haven't seen any issues. If I can narrow down the problem I'll do my best to fix it in the article and code.

Scott Dorman
Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA

[Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

GeneralRe: Different Info on Vista and XP
vinodonly
4:43 11 Jul '09  
Thanks for replying..

I'm getting following values on Vista. I have just formatted it for your convenience.

Net Framework 2 Ver : 2.0.50727.4016 - Service Pack 2
Net Framework 3 Ver : 3.0.30729.4037 - Service Pack 2
Net Framework 3.5 Ver : 3.5.30729.1 - Service Pack 1

and following values on XP.

Net Framework 2 Ver : 2.2.30729 - Service Pack 2
Net Framework 3 Ver : 3.2.30729 - Service Pack 2
Net Framework 3.5 Ver : 3.5.30729.1 - Service Pack 1

You can see that only for 3.5 framework it is returning identical values. For version 2 and 3 it is returning incorrect version. Service Pack Info is correct for all frameworks.
GeneralRe: Different Info on Vista and XP
vinodonly
23:52 14 Jul '09  
Any luck on this ?
GeneralRe: Different Info on Vista and XP
vinodonly
22:35 14 Sep '09  
Any update on this..
GeneralGreat article
Todd Chen
3:28 13 Apr '09  
Wow! It can detect .Net 3.5
I was looking for it, thank you.

Todd
http://nogeekhere.blogspot.com/[^]
GeneralBug?
rvade
11:41 5 Nov '08  
In GetRegistryValue, GetValueKind() is called before GetValue() which causes an exception if the value does not exist.
I ran into this exception when executing the code on a machine which previously had 3.5 installed and then uninstalled.
The fix is to switch the order:

if (registryKey != null)
{
// If the key was opened, try to retrieve the value.
object regValue = registryKey.GetValue(value, null);
if (regValue != null)
{
RegistryValueKind kindFound = registryKey.GetValueKind(value);
if (kindFound == kind)
{
data = (T)Convert.ChangeType(regValue, typeof(T), CultureInfo.InvariantCulture);
success = true;
}
}
}

GeneralA word of caution
joomlathug
3:42 2 Sep '08  
I use the NSIS free open source installer to install .NET s/w.

I used only to read registry entries to detect what framework was present.

After issues with a few customers, I discovered that if a target workstation has had a rough life (reinstalled OS after malware crash etc. etc.) it is sometimes possible to find orphaned registry entries that give a false positive for a framework that is not actually installed. Only way to be 100% sure is to run a framework-specific function and see if it fails.

Nice code though - and 99% of the time it's enough.
GeneralRe: A word of caution
Scott Dorman
5:13 2 Sep '08  
Thanks for the information. I actually saw some references to this on Aaron's blog. As soon as I find some free time I will be updating the article and code to reflect this and include a fix/workaround for it.

Scott Dorman
Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA

[Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

QuestionRe: A word of caution
Paul Selormey
3:28 5 Sep '08  
Any progress so far? I will also need this update.

Best regards,
Paul.


Jesus Christ is LOVE! Please tell somebody.

AnswerRe: A word of caution
Scott Dorman
15:06 7 Sep '08  
Paul Selormey wrote:
Any progress so far? I will also need this update.


Soon (hopefuly in the next few days). I finished updating the code today, so I still need to do a bit more testing and then make sure the actual article doesn't need updating. This version does not include the ability to verify the Framework by loading mscoree as I don't think I can load that library from inside .NET since that would mean that I have a .NET process hosting another version of the runtime. I'll post this update (which includes some extra safety checks on some of the registry keys) and continue investigating the ability to load mscoree.

Scott Dorman
Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA

[Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

AnswerRe: A word of caution
Scott Dorman
11:09 8 Sep '08  
I just published an update for some of these issues. Let me know if it resolves any of your issues.

Scott Dorman
Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA

[Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

GeneralRe: A word of caution
Paul Selormey
13:44 8 Sep '08  
Scott Dorman wrote:
I just published an update for some of these issues.

Thank you very much.

Scott Dorman wrote:
Let me know if it resolves any of your issues.

There are not real issues, I need to use your codes (have bookmarked it since I saw it at CodePlex) and prefers to start with the latest edition without/less issues.
I am working on a build library for Sandcastle, and it requires .NET 2.x to be installed, but allows users to build documentations for all versions of .NET, so knowing which versions of the .NET are installed is all I needed.

Best regards,
Paul.


Jesus Christ is LOVE! Please tell somebody.

GeneralRe: A word of caution
Scott Dorman
16:49 8 Sep '08  
You're welcome.

Paul Selormey wrote:
knowing which versions of the .NET are installed is all I needed.


Be sure to check out the new InstalledFrameworkVersions property. It sounds like this will easily give you the information you need.

Scott Dorman
Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA

[Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

GeneralRe: A word of caution
Scott Dorman
11:08 8 Sep '08  
I just published an update that tries to take some of these issues into account. Let me know if it resolves any of your issues.

Scott Dorman
Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA

[Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

GeneralRe: A word of caution
joomlathug
1:49 9 Sep '08  
Thanks fantastic.

Thanks!
GeneralThank for the excellent code
maxxnostra
17:43 14 Jun '08  
There is a much easier way to detect and install .NET framework if not present. It is pre-requisite in your VS.NET setup/deployment project. If you select .NET framework as a pre-requisite the SETUP.EXE along with the msi/cab will be generated to check if selected version is installed and install it if needed. I almost never need to do my own checks as I always build my deployment projects with setup/prerequisites checks. This works well when all dependencies in the project would run on the the target CLR. However I do have few external resourses compliled in the old 1.1 framework that are failing (strange enough) if there is not 1.1 CLR even though 2.0 CLR should sufice. I kind of like this class because it could be wrapped in the the deployment project and check for installed versions/service packs needed for the app to run properly. For example my project has some external dependencies on 1.1 framework but the project it self is build on 3.5 (2.0 CLR). THe setup will detect if 3.5 framework is installed and will install if needed but the dependency in my project will fail if no 1.1 framework is installed. Using this library I can warn the user or include the 1.1 redistributable to be isntalled if needed.

Thank you for the excellent code.
GeneralRe: Thank for the excellent code
Scott Dorman
2:58 15 Jun '08  
maxxnostra wrote:
There is a much easier way to detect and install .NET framework if not present. It is pre-requisite in your VS.NET setup/deployment project. If you select .NET framework as a pre-requisite the SETUP.EXE along with the msi/cab will be generated to check if selected version is installed and install it if needed.


There are definately better ways to detect if a specific version of the Framework is installed at install time. This code, as I point out in the introduction to the article, really shouldn't be run as part of an installer prequisite check since it requires a version of the Framework to already be present in order to run.

Your scenario, however, is one of those cases where this code could be used. Since you know you already have a dependency on the Framework and have verified through the setup prerequisite checks that the Framework is present, you are only determining which specific versions of the Framework are available.

Scott Dorman
Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA

Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[Forum Guidelines][Articles][Blog]

GeneralUpdates for .NET Framework 3.5 Beta 2
Scott Dorman
17:30 17 Aug '07  
There were a few minor updates in the FrameworkVersionDetection class due to a registry change between the January 2007 CTP and Beta 2 of the .NET Framework v3.5, so the download for this article has been updated. Also, the article was updated to reflect the correct registry key for determining the exact installed version.


Scott.

—In just two days, tomorrow will be yesterday.

[Forum Guidelines] [Articles] [Blog]

QuestionDetecting if .NET Framework is installed at all
eagle_dev
10:17 20 Feb '07  
I have a .NET app where the end-users may not have .NET installed. Is there a way to detect if the Framework is installed without sending the ugly "Application Error - The application failed to initialize properly" ?

I would like to be able to somehow override this error message to tell the user to install .NET 2.0. Is there anyway to do something like this???

Thanks
AnswerRe: Detecting if .NET Framework is installed at all
Scott Dorman
14:27 20 Feb '07  
Yes, there are ways to detect if .NEt is installed as part of the install routine of your application. Generally this is done using a custom action in the installer. If you are using InstallShield 12, I'm pretty sure you can customize the text that is displayed fairly easily.

-----------------------------
In just two days, tomorrow will be yesterday.


Last Updated 8 Sep 2008 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010