Chris Shearer Cooper
2007-12-21 20:04:27 UTC
Sorry for the cross-post, I really don't know where to post this question
...
An object in my EXE uses CoCreateInstance() to create a COM object, which
happens to live in a DLL (in-process, apartment threading). Everything is
written in C++ under VS 2005.
The DLL generates events that the EXE needs to know about, so the EXE
creates an object that implements a particular interface, and then passes a
pointer to that object (interface) to the DLL's object. Now, when the DLL
wants to tell the EXE something, it just calls a function on that interface
and the magic happens. Yes, I do all the proper QueryInterface() and such.
What is strange, is that even though the DLL is supposedly running
in-process, sometimes when the EXE crashes, the DLL seems to live on. The
next time I run the EXE, I get strange errors from the DLL's COM object. I
shut down the EXE, restart it, and all is well. These strange errors only
occur the first time I run the EXE after the EXE has crashed (or been
stopped by the debugger).
So I guess two questions ....
1) Why would my COM object (in the DLL) live on? Why doesn't it die when
the EXE crashes?
2) Is there a better way to handle this, so that the EXE crashing doesn't
leave the DLL with a bad pointer?
Thanks!
Chris
...
An object in my EXE uses CoCreateInstance() to create a COM object, which
happens to live in a DLL (in-process, apartment threading). Everything is
written in C++ under VS 2005.
The DLL generates events that the EXE needs to know about, so the EXE
creates an object that implements a particular interface, and then passes a
pointer to that object (interface) to the DLL's object. Now, when the DLL
wants to tell the EXE something, it just calls a function on that interface
and the magic happens. Yes, I do all the proper QueryInterface() and such.
What is strange, is that even though the DLL is supposedly running
in-process, sometimes when the EXE crashes, the DLL seems to live on. The
next time I run the EXE, I get strange errors from the DLL's COM object. I
shut down the EXE, restart it, and all is well. These strange errors only
occur the first time I run the EXE after the EXE has crashed (or been
stopped by the debugger).
So I guess two questions ....
1) Why would my COM object (in the DLL) live on? Why doesn't it die when
the EXE crashes?
2) Is there a better way to handle this, so that the EXE crashing doesn't
leave the DLL with a bad pointer?
Thanks!
Chris