views:

150

answers:

1

I have an ActiveX control written in C++ that runs in Internet Explorer 8. Most of the time (approx 90%) when the tab or browser containing the control is closed, there is an access violation like this:

The thread 'Win32 Thread' (0x1bf0) has exited with code 0 (0x0).
Unhandled exception at 0x77b3b9fd in iexplore.exe: 0xC0000005: Access violation reading location 0x65007408.

The access violation occurs after the call to OnDestroy() but before the call to the control's destructor.

The debug output says:

No symbols are loaded for any call stack frame. The source code cannot be displayed.

None of my code is present in the stacktrace, although perhaps the heap was corrupted at some earlier point during execution.

What lifecycle events does an ActiveX control receive between the call to OnDestroy() and the control's destructor?

+1  A: 

As I understand, there is no strictly event lifecycle for an ActiveX, it depends on host side. If your control is used with some AJAX framework, for example, after OnDestroy() can be called OnCreate() without calling destructor. So, make sure you don’t have uninitialize actions inside OnDestroy() handler.

You can load control in ActiveX Control Test Container and play with Activate/Deactivate, maybe it will be helpful.

Enable Application Verifier from debugging tools for windows and make sure your debugger downloads OS debug symbols. In this case stack trace will be more informative.

Eugene
Thank you very much for your answer. The problem closing the browser seems to be related to an OnSetCursor() event handler being called before the control is ready for it early on in the control's lifecycle.
richj