O'Reilly logo

.NET Common Language Runtime Unleashed by Kevin Burton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required