Compartir a través de


Naming Primary Interop Assemblies 

For easy recognition, the name you select for a primary interop assembly should resemble the original COM type library name and be specific enough to guide developers to the correct assembly. As with other assemblies, the name of a primary interop assembly has a significant impact on the assembly's scope and use by multiple applications.

You define the name when you generate the primary interop assembly. You usually generate a primary interop assembly by importing a type library. For details on importing a type library, see Generating Primary Interop Assemblies.

Naming Elements

Primary interop assemblies must be signed with strong names using standard public key cryptography. In addition to the public key, there are two essential naming elements:

  • Assembly file name.

    The file name of the assembly must match the assembly name (not including the file name extension, such as .exe or .dll). By default, the import process uses the type library name, rather than the type library file name, to produce the assembly name and file name. The type library name and the type library file name are not necessarily identical. For example, if you import the MyTypeLib type library contained in the MyComponent.tlb file, your default assembly name becomes MyTypeLib and your default assembly file name becomes MyTypeLib.dll.

    As a general guideline, use the VendorName.LibraryName combination to identify a primary interop assembly. For example, to fully identify the MyTypeLib type library published by MyCompany, override the default assembly file name (MyTypeLib.dll) with MyCompany.MyTypeLib.dll when you import the type library.

  • Namespace name.

    When you import a type library, the process uses the type library name to produce the namespace name. By overriding the default namespace during the import process, you can specify the namespace name. Use the same naming convention for the namespace (VendorName.LibraryName) that you use for the assembly name.

Naming Considerations

Consider the following naming issues:

  • At some point in the future you might plan to implement a managed version of an existing COM technology. In this case, consider using the VendorName.LibraryName.Interop namespace combination for your primary interop assembly, reserving VendorName.LibraryName for the managed assembly.

  • Your naming strategy can also maintain source compatibility between the original COM type library and the primary interop assembly by using the default assembly name, file name, and namespace name. While less descriptive, this strategy is useful for well-known libraries, such as ADODB in Microsoft Visual Basic 6.0 (the ADO library).

See Also

Concepts

Producing Primary Interop Assemblies
Generating Primary Interop Assemblies
Customizing Primary Interop Assemblies
Distributing Primary Interop Assemblies to Developers