How to: Create Primary Interop Assemblies Manually
A less frequently used approach for producing a type library involves creating a primary interop assembly manually in source code by using a language that is compliant with the Common Language Specification (CLS), such as C#. This approach is useful when a type library is unavailable.
To generate a primary interop assembly in source code
Create an interop assembly in source code. For instructions, see Creating a Wrapper Manually. Note that you must include all COM types from the original type library when you create a primary interop assembly manually.
At the assembly level, apply the following attributes:
GuidAttribute , to specify the library identifier (LIBID) of the target type library.
PrimaryInteropAssemblyAttribute , to identify the assembly as a primary interop assembly.
You can also delay sign an assembly when compiling. For more information, see Delay Signing an Assembly.
The following code example applies the AssemblyKeyFileAttribute with a key file called CompanyA.snk and specifies that this assembly is a primary interop assembly supporting type library versions 4.2 and 5.2. As the example shows, you can wrap more than one version of a type library by applying additional assembly-level attributes.