How to: Register Primary Interop Assemblies

You must register all acquired primary interop assemblies on your development computer before you can reference them with Microsoft Visual Studio 2005. Visual Studio looks for and uses a primary interop assembly the first time that you reference a type from a COM type library. If Visual Studio cannot locate the primary interop assembly associated with the type library, it prompts you to acquire it or offers to create an interop assembly instead. Likewise, the Type Library Importer (Tlbimp.exe) also uses the registry to locate primary interop assemblies.

Although it is not necessary to register primary interop assemblies unless you plan to use Visual Studio, registration provides two advantages:

  • A registered primary interop assembly is clearly marked under the registry key of the original type library. Registration is the best way for you to locate a primary interop assembly on your computer.

  • You can avoid accidentally generating and using a new interop assembly if, at some time in the future, you do use Visual Studio to reference a type for which you have an unregistered primary interop assembly.

Use the Assembly Registration Tool (Regasm.exe) to register a primary interop assembly.

To register a primary interop assembly

  • At the command prompt, type:

    regasm assemblyname

    In this command, assemblyname is the file name of the assembly that is registered. Regasm.exe adds an entry for the primary interop assembly under the same registry key as the original type library.

Example

The following example registers the CompanyA.UtilLib.dll primary interop assembly.

regasm CompanyA.UtilLib.dll

See Also

Concepts

Programming with Primary Interop Assemblies

Locating Primary Interop Assemblies

Redistributing Primary Interop Assemblies