I have an application that makes a COM object accessible to external clients (by registering it in the ROT).
The object is implemented in C++ using ATL.
Question 1: Is it possible to determine whether one of the references held to my object originates from an out-of-process client?
Motivation: I need to release some related objects (that block some operations) when external references are removed, even when the external reference dies unexpectedly. I also want to avoid requiring the caller to "say goodbye".
I am using the same interface internally, so I can't work with a separate reference count for the interface. The exposed interface is IDispatch
-based, so no custom marshaling takes place.
Question 2: Is it possible to tell out-of-process references to an object (and/or all objects) that the object is no longer "alive"? Forcing any call on the out-of-process interface to return, e.g. RPC_E_DISCONNECTED
(in the same way as after terminating the server process, the client receives an RPC_E_SERVER_DIED
for every call).
Motivation: the shutdown process of the server may be initiated by the user, and may take a while. In that time, all calls from external clients block; it would be prudent to inform them earlier that the call does not succeed.