2012-05-23 81 views
1

使用Visual c + + 6.0,我創建了一個基於ATL的.EXE服務器。 (VC6,因爲我正在處理遺留代碼,.exe服務器,因爲我需要在進程外環境中測試操作,目前.exe服務器本質上是不可操作的)無法使用代理存根創建com對象dll

我已經構建並註冊了相應的代理存根DLL。

我有一個客戶端應用程序,並

  1. 的CoCreateInstance的IUnknown的一個調用的FinalConstruct在服務器對象和成功(所以服務器正確調用)
  2. OleRun返回IUnknown接口的成功上的IUnknown
  3. 的QueryInterface我的服務器對象的指針失敗,錯誤代碼爲0x8000402(無此類接口支持)IMarshall接口

se步驟從(comip.h :: CreateInstance)複製

問題似乎是proxystub DLL沒有被調用調試窗口)

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是我的服務器對象(基於IDispatch)的接口ID

TIA的任何援助

+0

你有沒有註冊的proxystub?您可以使用Process Monitor來查看COM是否嘗試加載proxystub,以及接下來會發生什麼。 – sharptooth

+0

out of proc COM服務器的生命週期是什麼樣的?它啓動然後立即退出?另外,你能描述一下你使用OleRun的原因嗎?我懷疑oleauto32.dll正在加載併爲你執行編組。你的問題沒有提到任何自定義接口,在這種情況下,需要發生的任何編組都可以通過oleaut32完成,並且不需要加載自定義代理/存根。 – Tra5is

+0

還有一個問題,調用Run的組件是否在Running Object Table中註冊自身? – Tra5is

回答

0

這有可能是你的問題是,這是貫徹落實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