Why would QueryInterface() fail when the interface is surely implemented and has built-in marshaller in Windows?

后端 未结 3 1294
予麋鹿
予麋鹿 2021-01-22 08:07

I have the following setup. There\'s a COM server that is installed into COM+ (to run in a separate process) and has this interface definition:

[object, uuid(\"I         


        
3条回答
  •  执念已碎
    2021-01-22 08:25

    One of the possible scenarios that matches the behavior is the following:

    • you don't have any marhshaling between caller and callee
    • the interface pointer is valid
    • however the object which implements IStream, does not have a corresponding COM_INTERFACE_ENTRY map entry and does not make the interface available, the caller might have obtained the pointer via non-COM way, e.g. direct C++ cast

    This is easy to check by QueryInterface'ing the stream on the caller side before the call.

    The callee in this scenario can just reinterpret_cast to IStream and have it nicely working.

提交回复
热议问题