Customizing Primary Interop Assemblies
You can modify a primary interop assembly to make the types within it more useable by .NET-based applications. For example, you can make the following changes:
- Rename or hide certain elements in the assembly.
- Add attributes to change marshaling behavior.
Because a primary interop assembly provides the official definitions of types in the type library it describes, you must take care when renaming or hiding elements. Other imported COM components might depend on these elements and developers who reference your primary interop assembly must understand the nature of the customizations. Always document your changes.
The technique you use to customize a primary interop assembly depends on the approach you use to generate the assembly. For details on these approaches, see Generating Primary Interop Assemblies. There are two customization techniques:
Customizing the output from the Type Library Importer (Tlbimp.exe).
If you use Tlbimp.exe to import a primary interop assembly, you can customize the resulting assembly by editing the Microsoft intermediate language (MSIL) type definitions. For instructions on customizing MSIL, see Editing An Interop Assembly. This topic also identifies several problems and solutions associated with importing COM types.
Customizing source code.
If you create type definitions manually in source code using a language that is compliant with the Common Language Specification (CLS), you can modify the types directly using a variety of attributes. For a list of attributes that you can apply to source code, see Applying Interop Attributes.
See Also
Producing Primary Interop Assemblies | Naming Primary Interop Assemblies | Generating Primary Interop Assemblies | Distributing Primary Interop Assemblies to Developers