为 COM 接口启用编组需要什么? [英] What is required to enable marshaling for a COM interface?

查看:12
本文介绍了为 COM 接口启用编组需要什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个没有类型库的 32 位 ATL COM 组件.它为一个给定的类提供了一个类工厂,该类实现了多个接口.

I have a 32-bit ATL COM component without a type library. It has a class factory for one given class that implements several interfaces.

当我将它用作进程内服务器时,一切正常 - 客户端调用 CoCreateInstance(),实例化对象,QueryInterface() 检索指向请求接口的指针.但是当我将组件放入 COM+ 时,我无法再实例化该类 - CoCreateInstance() 现在返回 E_NOINTERFACE.

When I use it as an in-proc server, everything works fine - the client side invokes CoCreateInstance(), the object is instantiated and QueryInterface() retrieves a pointer to a requested interface. But when I put the component into COM+ I no longer can instantiate the class - CoCreateInstance() now returns E_NOINTERFACE.

我认为问题在于 COM+ 由于缺少类型库而无法执行封送处理 - 它不知道该怎么做.我需要生成并注册一个类型库来解决这个问题还是有其他方法?

I believe the problem is that COM+ can't perform marshaling because of absence of type library - it has no idea how to do it. Do I need to generate and register a type library to resolve this or is there any other way?

推荐答案

Urk.我建议询问 microsoft.public.vc.atl因为我认为你会在那里找到更多的专家.我认为(尽管我不是专家)这个问题与 COM+ 的关系不如注册代理/存根的问题.(换句话说,即使您编写了自己的 COM 客户端以在进程外访问您的组件,您也可能会遇到同样的问题)如果您有标准的自动化兼容接口,那么 Windows 就知道如何编组您的对象美好的.但否则它会感到困惑.

Urk. I would recommend asking on microsoft.public.vc.atl as I think you will find more experts there. I think (though I'm not an expert) the issue has less to do with COM+ than the issue of registered proxy/stubs. (In other words, even if you wrote your own COM client to access your component out-of-process, you would probably run into the same issue) If you have standard Automation-compatible interfaces, then Windows knows how to marshal your objects just fine. But otherwise it is confused.

如果没有类型库,您要么需要注册代理/存根,要么需要自己实现 IMarshal 来处理自定义封送处理.(或者还有这个我不明白的处理程序编组"的东西)

Without a type library, you either need to register proxy/stubs, or need to implement IMarshal yourself to handle custom marshaling. (or there's also this "handler marshaling" thing that I don't understand)

您关于为什么没有类型库的评论(实现了微软已经定义的接口,但没有类型库)向我提出了一个危险信号.你能提供更多细节吗?如果它在 .DLL 或 .EXE 中,但类型信息在库本身内部(而不是外部 .TLB 文件),则可能可以提取正确的信息以使一切正常,我只是不熟悉过程.

Your comment about why you don't have a type library (implementing an interface already defined by Microsoft, but one which doesn't have a typelib) raises a red flag with me. Can you provide more details? If it's something in a .DLL or .EXE, but the type information is inside the library itself (rather than an external .TLB file) it's probably possible to extract the right information to make everything work, I'm just not familiar with the process.

(作为记录,我已经放弃了 ATL/COM 编程,转而使用 Java,所以虽然我可以让你知道我过去记得的事情,但我现在不使用这些工具,这对我来说会很困难回到他们那里提供更多帮助.但是 microsoft.public.vc.atl 上的人非常聪明.)

(For the record, I've left ATL/COM programming in favor of Java, so although I can let you know what I remember in the past, I don't use the tools now and it would be difficult for me to get back into them to provide any more help. But the folks on the microsoft.public.vc.atl are pretty smart.)

这篇关于为 COM 接口启用编组需要什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆