Share via


Adding, Associating, and Deleting Type Libraries

You use the Associations editor to set up Windows registration of COM objects installed with your product in Microsoft® Visual Studio® Installer. In order to install and register COM objects in a way that takes advantage of the rollback and advertising features of the Microsoft® Windows® installer, you must associate each installed COM object with a type library. The Associations editor in Visual Studio Installer provides the means to manage type libraries in your installer project and associate them with COM objects.

This topic explains how to:

  • Prepare to add type libraries to an installer project.

  • Add type libraries to an installer project.

  • Prepare to establish type library associations.

  • Associate type libraries with COM objects.

  • Delete type libraries from an installer project.

Before adding type libraries

You can add only existing type libraries to an installer project; you can not create type libraries in the installer project. Any existing type library will already have been associated with a COM object outside of your installer project, but you must reestablish that association within the installer project.

To add an existing type library to an installer project, you must know the LibID (the GUID uniquely identifying the type library). Several strategies are available for determining the LibID of a type library.

To find the LibID for an object from this source Do this
Microsoft® Visual Basic® or a third-party control you do not have source code for Use the Visual Studio OLE/COM Object Viewer.

For more information, search for "OLE/COM Object Viewer" in the MSDN™ Library (Entire Collection).

Note   When you create a sharable COM object in Visual Basic, you should use the Binary Compatibility option to preserve its CLSID between versions. For more information, search for "binary compatibility" in MSDN Library, Visual Basic Documentation.

Microsoft® Visual C++® Use the Visual C++ Object Viewer, or examine the appropriate header (.h) or Interface Definition Language (.idl) file for COM object information, including the LibID of an associated type library.

For more information about the Object Viewer, search for "OLE/COM Object Viewer" in the MSDN Library (Entire Collection).

To add type libraries

  1. Find the LibID for the type library you are adding to the installer project. For information about how to do this, see Before adding type libraries.

  2. In the Project Explorer window, expand the Target Machine node under your installer project. Then, double-click Associations.

    The Associations editor is displayed.

  3. Right-click anywhere in the Associations editor.

  4. Select Add Type Library from the context menu.

    A new type library is added to your project with a default LibID and shown in the Type Libraries node in the Associations editor.

  5. Change the default LibID by typing over it. You can also change a LibID by entering the new one in the LibID property (in the Properties window) for the selected type library.

    Important   You must change the default LibID so it matches the original LibID. For information about looking up the LibID for COM objects, see Before adding type libraries.

  6. To establish the link between this type library and its associated COM object, see To associate type libraries with COM objects.

Before establishing type library associations

To facilitate correct COM object installation and registration on the target machine, you can associate type libraries with COM objects in your installer project. Before you can make this association, both the COM object and the type library must already be part of the installer project. For more information about adding these items to an installer project, see:

To associate type libraries with COM objects

  1. Make sure the type library and COM object you are associating have been added to the installer project. For information about adding these elements, see Before establishing type library associations.

  2. Display the Associations editor.

  3. In the Associations editor, expand the Type Libraries node to show the type library you want to associate with a COM object.

  4. In the Type Libraries node, select the type library you want to associate with a COM object.

  5. In the Properties window, change the type library Component property so it matches the Component property for the associated COM object. (You can see the COM object Component property in the Properties window when you select the COM object.)

    For more information about the type library and COM object component property, see Type Library Properties and COM Object Properties.

To delete type libraries

  1. Display the Associations editor.

  2. If necessary, expand the Type Libraries node to show the type library you want to delete.

  3. In the Type Libraries node, right-click the type library you want to delete.

  4. Select Delete from the context menu.

    The Type Libraries node shows the type library has been deleted from the installer project.