I have to use third party, unmanaged COM dll into my .NET application. I need to modify this assembly to produce a custom RCW. In order to Edit Interop Assembly I need the type library of the particular assembly. Can any one explain me that how to How to generate type library from unmanaged COM dll?
There is no option in regsvr32 to generate type library.
Thank you, Best Regards, Robo.
You need the OLE-COM Object Viewer, available as part of whatever is the latest Windows SDK. Then you can go to File->View Type Lib and save the IDL to a text file. Then you can use MIDL (also part of the Windows SDK) to regenerate a TLB and header file. Something like this should do for basic cases:
midl /out c:\temp /header MyHeader.h MyIDLFile.idl
If all you're trying to do is create an Interop Assembly from a native dll (and the native DLL embeds the TLB as a resource), you can just call tlbimp directly on the dll:
tlbimp Foo.dll /out:Interop.Foo.dll
Which will generate Interop.Foo.dll. You can then use ildasm to modify the IL:
ildasm Interop.Foo.dll /out=Foo.il
If all you have is that COM DLL, you can't generate a type library. A type library describes the COM interfaces implemented. But an unmanaged COM DLL merely needs to expose DllGetClassObject
. This only gets you an IClassFactory
, which lets you create new objects if you knwo the correct type up front.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With