In COM how does one verify that a pointer to a COM object still has a valid object on the other end?
I have an issue where this following bit of code attempts to check if the m_pServer
pointer is still alive, however when that application exposing that interface is killed this bit of code crashes the application. Can anybody advice on how to check the pointer before using it?
if (FAILED(m_pServer->StillAlive())) { // do something }
This code fails if m_pServer is no longer in memory.
EDIT:
EXCEPTION: First-chance exception at 0x7728fbae (kernel32.dll) in Client40.exe: 0x800706BA: The RPC server is unavailable.
CALL STACK:
kernel32.dll!RaiseException() + 0x58
rpcrt4.dll!RpcRaiseException() + 0x3e
rpcrt4.dll!NdrProxyErrorHandler() + 0x28
rpcrt4.dll!NdrProxySendReceive() + 0xa4
rpcrt4.dll!NdrProxySendReceive() + 0x119
rpcrt4.dll!NdrComplexArrayMarshall() + 0x26d
--> Client40.exe!SlaveDriver::run() Line 97 + 0x14 C++ //Runs while loop, to handle requests
Client40.exe!DThread::tfunc(void * thisptr=0x0047e694) Line 56 + 0xd C++
Client40.exe!_threadstartex(void * ptd=0x01b20e00) Line 241 + 0xd C
kernel32.dll!BaseThreadInitThunk() + 0x12
ntdll.dll!RtlInitializeExceptionChain() + 0x63
ntdll.dll!RtlInitializeExceptionChain() + 0x36