Inspecting an Assembly for COM Types
This section describes ways to inspect COM type information (as metadata) to determine the signature of the methods you want to call from your .NET client.
Namespaces and COM Objects
Metadata for a coclass is placed in a namespace with the same name as that of the type library from which the metadata was created. For example, if you convert a type library named LoanLib to an assembly file named LOANLib.dll and that type library contains a class named Loan, the namespace created would be named LOANLib, and the fully resolved name of the class would be LOANLib.Loan.
You can alter the namespace by using the /namespace: option of the Tlbimp tool.
Inspecting Metadata with the Type Class
The System.Type class provides methods to inspect metadata. If the COM type has accompanying metadata (produced with the Type Library Importer or equivalent API), complete information is available about the type through the instance of the Type class. If the COM type does not have accompanying metadata, the Type provides relatively little information.
Viewing Metadata with MSIL Disassembler
The .NET Framework SDK provides the Microsoft intermediate language (MSIL) Disassembler (Ildasm.exe), which is a graphical tool to display metadata in a hierarchical tree view. This tool provides readable descriptions of the metadata and is similar to OleView (a tool often used in COM development efforts).
Ildasm.exe displays metadata for any managed portable executable (PE) file, including type libraries imported as assembly files. For example, if you import a type library named LoanLib to an assembly file named LOANLib.dll, you can view the managed types in the assembly.
To view metadata with Ildasm.exe
- Use the following command to display metadata for LOANLib.dll:
The LOANLib.dll comprises type definitions for the Loan class and the ILoan interface. Ildasm.exe displays member descriptions for the Loan class and ILoan interface.