Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I load a typelib to parse it in C#?

Tags:

c#

.net

com

typelib

In unmanaged code I can use LoadTypeLib() to obtain an ITypeLib* pointer and use that to look into the typelib to find what interfaces it contains.

There is System.Runtime.InteropServices.ComTypes.ITypeLib interface in C# but I can't find an equivalent to LoadTypeLib() function.

How do I load a typelib and obtain an ITypeLib reference in C#?

like image 870
sharptooth Avatar asked Nov 23 '12 13:11

sharptooth


1 Answers

Copied straight from System.Design.NativeMethods, Reflector is useful:

[DllImport("oleaut32.dll", PreserveSig=false)]
public static extern ITypeLib LoadTypeLib([In, MarshalAs(UnmanagedType.LPWStr)] string typelib);
like image 76
Hans Passant Avatar answered Nov 14 '22 08:11

Hans Passant