How to detect the installed version of the .NET Framework in a Visual Studio Setup and Deployment package (315291)



The information in this article applies to:

  • Microsoft .NET Framework 1.0
  • Microsoft .NET Framework 1.1
  • Microsoft .NET Framework 2.0
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio 2005 Professional Edition

This article was previously published under Q315291

INTRODUCTION

This step-by-step article describes how to use the Microsoft Visual Studio .NET IDE to verify the version of the .NET Framework that is installed on a client computer for software installation purposes.

Note This article does not show you how to programmatically detect the .NET Framework in a managed application. The scenario that is covered in this article is a deployment scenario where a developer is not sure of the version of the .NET Framework that is installed on the client computer. This article also does not show you how to detect if a service pack is installed in the .NET Framework.

back to the top

MORE INFORMATION

Required knowledge

This article assumes that you are familiar with the following topic:

Visual Studio .NET deployment and setup projects

back to the top

Detect the current installed version

To add a launch condition in the deployment project against the .NET Framework version registry key, follow these steps:
  1. Create a new Visual Studio Setup project from the Setup and Deployment project type.
  2. Start Solution Explorer, and then open Launch Conditions Editor from the Solution Explorer toolbox.
  3. In Launch Conditions Editor, right-click the Search Target Machine node, and then click Add Registry Search.
  4. Type an appropriate name for the search, such as "Search CLR version."
  5. Click the new search, and then press F4 to open Launch Condition Properties. Alternatively, on the main menu, click View, and then click Properties Window.
  6. Set the RegKey property to one of the following values:

    For the .NET Framework 1.0:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v1.0

    For the .NET Framework 1.1:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v1.1

    For the .NET Framework 2.0:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v2.0

  7. Set the Value property as follows:
    • For the .NET Framework 1.0: "3705"
    • For the .NET Framework 1.1: "4322"
    • For the .NET Framework 2.0: "50727"
  8. In the Launch Conditions node, add a new launch condition. To do this, right-click the node, and then click Add Launch Condition. Give this condition an appropriate name, such as "CLR condition."
  9. Click the new condition, and then set the Condition property as follows:
    • For the .NET Framework 1.0:
      REGISTRYVALUE = "3321-3705"
    • For the .NET Framework 1.1:
      REGISTRYVALUE="3706-4322"
    • For the .NET Framework 2.0:
      REGISTRYVALUE="50727-50727"
  10. Set the Message property to an output message, such as "The .NET Framework 1.0 is not installed.", "The .NET Framework 1.1 is not installed.", or "The .NET Framework 2.0 is not installed."
  11. Build and test the deployment project.
Note For testing purposes on the computer that you use for development you may modify the registry as follows. For all of the examples the placeholder XXX is the version of the .NET Framework that you are testing.

Locate the following key for the .NET Framework 1.0:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v1.0

Rename the previous key to the following:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\XXXv1.0

Locate the following key for the .NET Framework 1.1:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v1.1

Rename the previous key to the following:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\XXXv1.1

Locate the following key for the .NET Framework 2.0:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v2.0

Rename the previous key to the following:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\XXXv2.0


Do not forget to rename the key after you complete your test.
back to the top

REFERENCES

For additional information, visit the following Microsoft Developer Network (MSDN) Web sites: back to the top

Modification Type:MajorLast Reviewed:1/17/2006
Keywords:kbHOWTOmaster KB315291 kbAudDeveloper