将两个 .IDL 文件或两个 .tlb 文件合并为一个文件

发布于 2024-09-13 16:07:05 字数 299 浏览 11 评论 0原文

我有 2 个 .net dll,我使用 REGASM 将其公开给 COM。为了简化 COM 客户端内的引用,我想将它们放入一个文件中。

我尝试将两个文件都转换为 IDL,然后将一个文件的库部分的内容复制到另一个文件中,然后使用 MIDL 编译回 .tlb。这对于第二个 IDL 中的 TypeDef 工作得很好,但是当涉及到我复制的接口时,它似乎失败了。OLE/COM 查看器可以看到接口定义,但是当我尝试通过 COM 使用 TLB 时,它无法找到该接口我复制了进去。

在我花太多时间在这上面之前,我想先确定一下,实际上可以通过这种方式来减少 IDL。

I have 2 .net dll's which I expose to COM using REGASM. In order to simplify referencing within a COM client I would like to make these into one file.

I have tried converting both files to IDL and then copying the contents of the Library section of one into the other and then compiling back to .tlb with MIDL. This works fine for the TypeDefs within the second IDL however it seems to fail when it comes to the interfaces I copied in. OLE/COM viewer can see the interface definitions but when I try and use the TLB via COM it cant find the interfaces that I copied in.

I wanted to make sure before I spend too much time on this, that it is actually possible to meagre IDL's in this way.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

林空鹿饮溪 2024-09-20 16:07:05

您可以使用 ILMerge 首先组合 .NET 程序集,然后对生成的程序集使用 REGASM?

ILMerge 是一个用于合并的实用程序
将多个 .NET 程序集合并为一个
.NET 程序集。它适用于可执行文件
和 DLL 类似,并带有几个
控制处理的选项
和输出的格式。

Could you use ILMerge to first combine the .NET assemblies and then use REGASM on the resulting assembly?

ILMerge is a utility for merging
multiple .NET assemblies into a single
.NET assembly. It works on executables
and DLLs alike and comes with several
options for controlling the processing
and format of the output.

玻璃人 2024-09-20 16:07:05

我看不出有什么明显的方法会失败。您说您合并了库部分,但没有说您从其他 .idl 复制粘贴了接口声明。这是一个显而易见但不太可能的解释。

一种失败模式是客户端应用程序使用类型库跨单元边界或进程外编组接口指针。然而,这需要 HKCR\Interfaces 中的注册表项。 .NET 不会创建它们,您必须自己创建它们。如果你这样做了你就会知道,也不需要太多解释。

I don't see an obvious way this would fail. You said you merged the library sections but you didn't say you copy-pasted the interface declarations from the other .idl. That would be an obvious, but unlikely, explanation.

One failure mode is when the client app uses the type library to marshal interface pointers across apartment boundaries or out-of-process. That however requires registry keys in HKCR\Interfaces. .NET doesn't create them, you'd have to do that yourself. You'd know if you did, not much of an explanation either.

扭转时空 2024-09-20 16:07:05

好吧,事实证明我遇到的问题与合并 idl 无关。

如果您希望合并到 idl,只需将一个 idl 中库部分的内容复制到另一个 idl 中即可。然后对合并的文件运行 midl 将其转换为 tlb。

Ok so it turns out that the issues I was experiencing were not related to merging the idl's.

If you wish to merge to idl's you can do so by simply copying the content of a library section in one idl into another. Then run midl on the merged file to turn it into a tlb.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文