Partager via


Exported Assembly Conversion

Any tool or API that exports an assembly to a type library must convert the outermost level of a managed assembly first. The process converts each individual assembly into a single type library, imposing one-to-one mapping between assembly and type library. You cannot split an assembly into multiple type libraries. An assembly consistently produces the same type library, regardless of the details or manner of its conversion.

Assembly and Type Library Identities

An assembly identity consists of the four elements listed in the following table.

Element Description
Name String used to identify the assembly. Typically, this string is the same as the assembly file name without the extension.
Public key Public part of a public/private cryptographic key pair.
Version Four-part numeric string consisting of the major, minor, build, and revision numbers.
Culture string Locale that the assembly supports.

In combination, these fields produce a strong name to identify an assembly.

Partial assembly manifest

.assembly Sample as "Sample"
{
    publickey = (00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00   
                 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00   
                 B7 3C 60 FD 2D 6B E4 14 4E BD D1 B6 1A 09 FB F1   
                 23 FF A8 62 59 B3 86 0B 0A 73 10 98 51 E5 0E D6   
                 7E 10 2F A7 6E AF 1B E5 E8 F1 2E E6 9C F7 74 9A   
                 1A 9A 83 88 2C 70 C9 8B 52 AD 97 5C 23 52 D2 42   
                 D2 6C 64 14 E7 1D 1D 55 B4 F4 9C BB 86 7B 07 99   
                 E3 19 E8 E1 4A BC 7A 40 A6 A2 9D AD 96 9B E5 CA   
                 7C 10 5B 79 16 80 29 50 CD C3 63 D0 12 81 D0 18   
                 B4 AE DA EC CC ED 8E AF A4 08 14 05 C6 9C 7B C5)
  .ver 1:0:295:37445
  .locale = (65 00 6E 00 2D 00 55 00 53 00 00 00 )   // en-US
}

In contrast, a type library identity consists of three elements: a library identifier (LIBID), the version, and a Local Identification (LCID). Neither the name of the file containing the type information, nor the friendly name defined within the library, is part of the library's identity. You can locate a type library through the registry by using its LIBID, version, and LCID.

Type library representation

[ uuid(0D26FC72-7EB1-4565-AA75-DA5F177EFA66),
  lcid(0x0409), 
  version(2.1), 
  helpstring("Acme Widget Library")
] 
library Acme 
{
...
}; 

Library Identifier (LIBID)

When the export process converts an assembly to a type library, it preserves the identity of the library. Each uniquely identified assembly becomes a uniquely identified type library. To ensure uniqueness, the conversion process uses the name, version, and public key from an assembly to produce a LIBID.

Specifically, the combination provides the following guarantees:

  • A name, version, and public key combination consistently yields the same LIBID.
  • Two assemblies with different name, version, and public key combinations never produce the same LIBIDs.

You can apply the GuidAttribute to explicitly set the LIBID.

Version and Build Number

The conversion process also passes version information from the assembly to the type library, although type libraries contain only a two-part version number, while assemblies contain a four-part version number. The major and minor version numbers of an assembly are carried forward to the type library. Assembly build numbers are discarded in the conversion, which indicates that two assemblies differing only by their build numbers always yield the same type library. Assemblies with 0 representing the major and minor numbers (0.0.X.X) produce a type library with a 1.0 version number.

In general, there are no guarantees about the contents of a type library generated from multiple assembly versions. A type defined in version 1.0 of a particular library is not guaranteed to be in a second version of the same library.

Locale Information

An assembly's locale identifier string (us-en, for example) is converted to an LCID and stored in the LCID field in the type library. If the locale identifier string is absent in the assembly, the export process sets the LCID to 0.

Periods to Underscores

Assembly names often contain periods, which are not permitted in type library names. The export process converts periods in the name field of an assembly to underscores.

Helpstrings

The export process copies the AssemblyDescriptionAttribute if applied to an assembly at design time, to the helpstring or DocString associated with a type library. Neither the HelpFile field nor the HelpContext field in the type library is set. None of the LIBFLAGS in the type library is set.

Other Assembly Fields

Other assembly fields such as Processor, OSInformation, CodeBase, Alias, AssemblyHash, Configuration, and Flags are discarded during the conversion.

The export process does not set type library attributes, such as hidden, restricted, and control.

See Also

Assembly to Type Library Conversion Summary | Exported Module Conversion | Exported Type Conversion | Exported Member Conversion | Exported Parameter Conversion