开发者

Invoke call on released COM object

I create a COM object used for automation tasks of some application. When this happens application is started and its' main window is displayed.

The problem happens when user closes the main application w开发者_开发技巧indow. Next Invoke call to the COM object does not work. The problem is that it does not fail and it does not report an error. If I put a debugger breakpoint in next line of code, it is never reached. If I surround the Invoke call with try/catch, no exception is caught. In release build it just crashes.

How is this supposed to work? Since I use CComDispatchDriver as a wrapper around IDispatch* I would expect that my AddRef would keep the COM object alive even if user closed the application. I was hoping of at least getting some HRESULT as an error.


What probably happened is that your application called CoUninitialize when exiting. CoUninitialize causes all COM object to be discarded, thus if you ever interact with the COM object after calling CoUninitialize, you'll crash.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜