如何在命令行上从 COM exe 中提取 TypeLib
我最近需要生成一个互操作程序集。经过一番谷歌搜索后,我发现了 tlbimp.exe。我的下一个问题是我的 COM 库没有附带 .tlb
文件。进一步的谷歌搜索显示,类型库通常作为资源包含在 exe/dll 中。果然,在 VS2010 中打开 exe,发现它的类型是 lib,然后右键单击,我得到了一个可与 tlbimp 一起使用的 tlb 文件。惊人的。
然而,这不是一个很好的过程。如果我将来需要这样做,有没有办法使用命令行从 .exe 中提取类型库(.tlb 文件)?
I've recently had need to produce an interop assembly. After some googling I discovered tlbimp.exe
. My next problem was that my COM library did not come with a .tlb
file. Further googling revealed that the type lib is often included as a resource in an exe/dll. Sure enough, opening the exe in VS2010 revealed it's type lib and a right-click later I had a tlb file to use with tlbimp
. Awesome.
However this is not a very nice process. Should I need to do this in the future, is there a way of extracting a Type Lib (.tlb file) from a .exe using the command line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Tlbimp.exe 可以很好地处理 EXE 内的类型库资源。例如:顺便说一句
,自动化这是相当危险的。类型库与程序集引用非常等效。如果它改变了,你想知道它。不仅仅是因为您可能必须修改互操作代码并重新测试它,DLL Hell 也正在敲您的门。
Tlbimp.exe can handle a type library resource inside an EXE just fine. For example:
Automating this is fairly risky btw. A type library is quite equivalent to an assembly reference. If it changed you want to know about it. Not just because you may well have to modify your interop code and retest it, DLL Hell is knocking on your door as well.