HOW TO: Obtain the COM Registration Information in a Windows Installer Package by Using Microsoft Visual Studio .NET (827017)



The information in this article applies to:

  • Microsoft Windows Installer
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition

SUMMARY

This step-by-step article discusses how to obtain the COM registration information in a Microsoft Windows Installer package by using Microsoft Visual Studio .NET. You set registry launch conditions in your Visual Studio .NET Setup project to determine if the COM component is registered.

If you set registry launch conditions, AppSearch searches the registry for the COM registration, and then returns the search results as a property while installing the package. If the registry entry does not exist on your computer, the launch condition uses this property to quit the installation process.

In the sample, you create a Visual Studio .NET Setup project. In this project, you set the registry launch condition to search for the registry entry of the Mscorlib.dll file on your computer. If the Mscorlib.dll file is not registered on your computer, the launch condition quits the installation of the Windows Installation package.

back to the top

Requirements

The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:
  • Microsoft Windows 2000, Microsoft Windows XP, or Microsoft Windows Server 2003
  • Microsoft Visual Studio .NET
This article assumes that you are familiar with the following topics:
  • Visual Studio .NET Setup Projects
  • Launch Conditions
back to the top

Create a Setup Project

To create a Setup project by using Visual Studio .NET, follow these steps:
  1. Start Microsoft Visual Studio .NET.
  2. On the File menu, point to New, and then click Project.
  3. Under Project Types, click Setup and Deployment Projects.
  4. Under Templates, click Setup Project.
  5. In the Name text box, type MyApp, and then click OK.
back to the top

Add a Windows Application to the Setup Project

To add a Windows Application project to the Setup project, follow these steps:
  1. On the File menu, point to Add Project, and then click New Project.
  2. Under Project Types, click Visual Basic Projects.
  3. Under Templates, click Windows Application.
  4. In the Name text box, type MyWindowsApp, and then click OK.
  5. Add a Button control to Form1. By default, Button1 is created.
  6. Add the following code to the Button1_Click event handler:
     MessageBox.Show("This is a test Windows Application")
  7. In Solution Explorer, right-click MyWindowsApp, and then click Build.
  8. In Solution Explorer, right-click MyApp, point to Add, and then click Project Output.
  9. In the Add Project Output Group dialog box, click OK.
back to the top

Add a Registry Launch Condition to the Setup Project

To add a registry launch condition that searches for the registry entry of the Mscorlib.dll file based on the registry key that you provide in the Setup project, follow these steps:
  1. In Solution Explorer, right-click MyApp, point to View, and then click Launch Conditions.
  2. In the Launch Conditions Editor, right-click Requirements on Target Machine, and then click Add Registry Launch Condition.
  3. Right-click Search for RegistryEntry1, and then click Properties Window.
  4. In the Properties window, verify if the Root property is set to vsdrrHKLM.
  5. Set the RegKey property to the following:

    SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\9CD7C0343CB3E804297298BEA362A56C

  6. Set the Value property to the following:

    AA75334BD6A349D45BE6344CD4905E84

  7. Right-click Condition1, and then click Properties Window.
  8. In the Properties window, set the Condition property to the following:

    REGISTRYVALUE1<>" "

  9. Set the Message property to the following:

    Mscorlib.dll is not registered. Register the component to continue.

  10. In Solution Explorer, right-click MyApp, and then click Build.
back to the top

Verify That Your Application Works

  1. Locate the MyApp.msi file in the MyApp\Debug folder on your computer.
  2. Right-click MyApp.msi, and then click Install.
  3. If the Mscorlib.dll file is not registered on your computer, you receive the following message and the installation process is not completed:Mscorlib.dll is not registered. Register the component to continue.
back to the top

REFERENCES

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

307374 HOW TO: Use Launch Conditions in Visual Studio .NET

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


Modification Type:MinorLast Reviewed:5/23/2005
Keywords:kbHOWTOmaster kbhowto kbRegistry kbsetup kbDeployment KB827017 kbAudDeveloper