Application Details: 64 bit application, .Net Framework 2.0.
We have ATL control that hosts a managed UI control. In the Destructor of AL control we do call Dispose of the
Managed UI Control.
We use IDispEventImpl mechanism to sink the Managed control events. So our implementation of Manged UI Control does
not have any direct reference to ATL control. So we are not able to do ReleaseCOMObject in the Dispose of Managed UI control.
Scenario for crash:
We cocreate one instance of ATL Control that hosts a managed UI control. After the managed control is created it
has a reference to the unamanged ATL Control to fire back the events.
Then the first instance of ATL control is destroyed and the second instance will be created. After some time
application crashes. Because When GC got triggered and when it tries to collect the managed UI control hosted by
the first instance of ATL control, it is trying to release this ATL Control which has been destroyed already.
Similar problem is discussed in this below link:
Since managed UI Control do have reference to the ATL control directly we are not able to call ReleaseCOMObject as
View Complete Post