Symptom:
Com external components have a createdog (iunknown ** ppunk) method to create an idog interface. When you want to directly pass the spdog smart pointer to the createdog method, the interface passed back is found to be non-empty, and the returned value is s_ OK. However, when this pointer is used to call its method (the Qi function is no problem), an asserted pops up: unhandled exception... stack Overflow.
With the help of many parties, I finally found the root of the problem:
Because it is a component outside the process, you can only pass the iunknown ** interface pointer, (a classmate: I certainly know this, or else the parameter will not be iunknonw ), but why do I pass spdog to the function as a [out] parameter? You may assume that it is a "common and convenient" method to forcibly convert from iunknown to idog!
This is the problem! In the in-process components, it is no problem if we force the conversion in this way, because there is no column set operation for parameter transfer within the process (or exactly within the suite, however, the passed iunknown between processes is another one you get in the process. How can you expect that it also contains an idog vtable, therefore, the correct method should be that you get the iunknown pointer and then QueryInterface idog again. In this way, the obtained pointer is correct.
Summary:
In terms of Interface Usage, it is best not to forcibly convert from iunknown to the interface you want, but to adopt the standard practice: QueryInterface
Haha .. I made another mistake!