Programmatically Generating an Interop Assembly
The same functionality that is provided with the tlbimp utility is exposed in the TypeLibConverter class. To use this class, load a type library description. Listing 8.5 shows the most straightforward method to load a type library. The full source to this sample is available in the TypeLibraryConversion directory.
Listing 8.5. Loading a Type Library
private enum RegKind { RegKind_Default = 0, RegKind_Register = 1, RegKind_None = 2 } [ DllImport( "oleaut32.dll", CharSet = CharSet.Unicode, PreserveSig = false )] private static extern void LoadTypeLibEx(String strTypeLibName, RegKind regKind, [MarshalAs(UnmanagedType.Interface)] out Object typeLib); [STAThread] static void Main(string[] args) { Object ... |
Get .NET Common Language Runtime Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.