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.
To add a launch condition in the deployment project against the .NET Framework version registry key, follow these steps:
Create a new Visual Studio Setup project from the Setup and Deployment project type.
Start Solution Explorer, and then open Launch Conditions Editor from the Solution Explorer toolbox.
In Launch Conditions Editor, right-click the Search Target Machine node, and then click Add Registry Search.
Type an appropriate name for the search, such as "Search CLR version."
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.
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
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"
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."
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"
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."
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: