【问题标题】:Unable to create a com object using proxy stub dll无法使用代理存根 dll 创建 com 对象
【发布时间】:2012-05-29 13:50:43
【问题描述】:

使用 Visual c++ 6.0,我创建了一个基于 ATL 的 .EXE 服务器。 (VC6 因为我正在处理遗留代码,一个 .exe 服务器,因为我需要在进程外上下文中测试操作,目前 .exe 服务器基本上是无操作的)

我已经构建并注册了相应的代理存根DLL。

我有一个客户端应用程序

  1. IUnknown 的 CoCreateInstance 在服务器对象中调用 FinalConstruct 并成功(因此服务器被正确调用)
  2. 返回的 IUnknown 接口的 OleRun 成功
  3. 我的服务器对象的 IUnknown 指针上的 QueryInterface 失败,IMarshall 接口的错误代码为 0x8000402(不支持此类接口)

这些步骤复制自 (comip.h::CreateInstance)

问题似乎是proxystub dll没有被调用(它没有出现在IDE的模块列表中,也没有出现在调试窗口的加载模块列表中)

The OleCom Object viewer for my class and interface can be seen here https://skydrive.live.com/redir?resid=AE43106917EBD9E1!191&authkey=!AIOWeS5P3o2mlpw

8891..ca4d 是我的对象的类接口 ID

A298...420c 是我的服务器对象的接口 ID(基于 IDispatch)

TIA 寻求帮助

【问题讨论】:

  • 你注册了proxystub吗?您可以使用 Process Monitor 查看 COM 是否尝试加载 proxystub 以及接下来会发生什么。
  • out of proc COM 服务器的生命周期是什么样的?它启动然后立即退出吗?另外,您能描述一下您使用 OleRun 的原因吗?我怀疑 oleauto32.dll 正在加载并为您执行编组。您的问题没有提到任何自定义接口,在这种情况下,任何需要进行的编组都可以由 oleaut32 完成,并且不需要加载您的自定义代理/存根。
  • 还有一个问题,调用Run的组件是否在Running Object Table中注册了自己?
  • 是的,代理存根已注册
  • Out of proc 服务器不会立即退出,它会一直徘徊,直到客户端退出,OleRun 的用法是从 comip.h::CreateInstance 复制的,即扩展 _com_ptr_t::CreateInstance(clsid)。如果不在 PS DLL 中进行代理,会怎样?

标签: visual-studio com atl


【解决方案1】:

您的问题可能是实现 IRunnableObject 接口的组件未在运行对象表中注册自身。这意味着 CoCreateInstance 本身会成功,但是,当它调用对象时,RPC 代码将无法找到它。

此 MSDN 页面表明: http://msdn.microsoft.com/en-us/library/windows/desktop/ms694517(v=vs.85).aspx

    Notes to Implementers
    The object should register in the running object table if it has a 
    moniker assigned. The object should not hold any strong locks on itself; 
    instead, it should remain in the unstable, unlocked state. The object 
    should be locked when the first external connection is made to the object.

我有点担心您为什么还要使用 IMarshall 界面。通常不需要编写自定义编组代码,因此您不需要使用此接口。

只要您不引用自定义接口,就会使用 ole32.dll 或 oleauto32.dll 中的默认编组器。这很可能是您看不到代理被加载的原因。

    In the case of most COM interfaces, the proxies and stubs for standard 
    marshaling are in-process component objects which are loaded from a 
    systemwide DLL provided by COM in Ole32.dll.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms692621(v=vs.85).aspx

【讨论】:

    猜你喜欢
    • 2012-03-27
    • 1970-01-01
    • 2017-10-30
    • 2015-06-13
    • 1970-01-01
    • 2017-02-15
    • 2011-03-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多