Microsoft KB Archive/315291

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

Article ID: 315291

Article Last Modified on 12/3/2007

-

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

-



This article was previously published under Q315291



IN THIS TASK

 * INTRODUCTION
 * Required knowledge
 * Detect the current installed version
 * REFERENCES



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



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:  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 &quot;Search CLR version.&quot; 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

</li> Set the Value property as follows: <ul> For the .NET Framework 1.0: &quot;3705&quot;</li> For the .NET Framework 1.1: &quot;4322&quot;</li> For the .NET Framework 2.0: &quot;50727&quot;</li></ul> </li> 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 &quot;CLR condition.&quot;</li> Click the new condition, and then set the Condition property as follows: <ul> For the .NET Framework 1.0:

REGISTRYVALUE = &quot;3321-3705&quot;</li> For the .NET Framework 1.1:

REGISTRYVALUE=&quot;3706-4322&quot;</li> For the .NET Framework 2.0:

REGISTRYVALUE=&quot;50727-50727&quot;</li></ul> </li> Set the Message property to an output message, such as &quot;The .NET Framework 1.0 is not installed.&quot;, &quot;The .NET Framework 1.1 is not installed.&quot;, or &quot;The .NET Framework 2.0 is not installed.&quot;</li> Build and test the deployment project.</li></ol>

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  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\ v1.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\ v1.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\ v2.0

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

back to the top

<div class="references_section">