如何从非托管 COM dll 生成类型库

2022-01-14 00:00:00 com c++ typelib unmanaged regsvr32

我必须在我的 .NET 应用程序中使用第三方非托管 COM dll.我需要修改此程序集以生成 自定义 RCW.为了编辑互操作程序集我需要特定程序集的类型库.谁能解释一下如何从非托管 COM dll 生成类型库?

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?

regsvr32中没有生成类型库的选项.

There is no option in regsvr32 to generate type library.

谢谢你,最好的祝福,机器人.

Thank you, Best Regards, Robo.

推荐答案

如果您要做的只是从本机 dll 创建一个互操作程序集(并且本机 DLL 将 TLB 作为资源嵌入),您可以直接在 dll 上调用 tlbimp:

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

这将生成 Interop.Foo.dll.然后可以使用 ildasm 来修改 IL:

Which will generate Interop.Foo.dll. You can then use ildasm to modify the IL:

ildasm Interop.Foo.dll /out=Foo.il

相关文章