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

Article translations Article translations
Article ID: 315291 - View products that this article applies to.
This article was previously published under Q315291
Expand all | Collapse all

On This Page

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.

MORE INFORMATION

Required knowledge

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

Visual Studio .NET deployment and setup projects

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.

REFERENCES

For additional information, visit the following Microsoft Developer Network (MSDN) Web sites:
Creating or adding deployment projects
http://msdn.microsoft.com/en-us/library/aa291133.aspx

Adding items to a deployment project
http://msdn.microsoft.com/en-us/library/aa291131.aspx

Properties for the Launch Conditions Editor
http://msdn.microsoft.com/en-us/library/aa291900.aspx

Adding a launch condition in the Launch Conditions Editor
http://msdn.microsoft.com/en-us/library/aa301646.aspx

Properties

Article ID: 315291 - Last Review: December 3, 2007 - Revision: 6.6
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
  • Microsoft Visual Studio .NET 2002 Academic Edition
  • Microsoft Visual Studio .NET 2002 Enterprise Developer
  • Microsoft Visual Studio .NET 2003 Academic Edition
  • Microsoft Visual Studio .NET 2003 Enterprise Architect
  • Microsoft Visual Studio .NET 2003 Enterprise Developer
  • Microsoft Visual Studio .NET 2003 Professional Edition
  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio 2005 Professional Edition
Keywords: 
kbhowtomaster KB315291

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com