While adding tests for AxSystemMonitor in #10675 , it was found that we get an HRESULT error while attempting to dispose of the control. There is an odd call to IOleObject.SetClientSite(null) in AxHost.DisposeAxControl that gives back HRESULT.E_POINTER when attempting to dispose an ActiveX control. We have always been passing null to IOleObject.SetClientSite since Framework so it is unclear whether or not this method has ever succeeded. The docs seems to indicate that it is ok to pass null pointer so we should investigate what is happening in the windows code and determine next steps to resolve this.
Repro (could also use other active x controls):
using Form form = new();
using AxSystemMonitor.AxSystemMonitor control = new();
((ISupportInitialize)control).BeginInit();
form.Controls.Add(_control);
((ISupportInitialize)_control).EndInit();
Once fixed, we should also update our tests that test ActiveX controls to dispose of them properly.
While adding tests for
AxSystemMonitorin #10675 , it was found that we get an HRESULT error while attempting to dispose of the control. There is an odd call toIOleObject.SetClientSite(null)inAxHost.DisposeAxControlthat gives backHRESULT.E_POINTERwhen attempting to dispose an ActiveX control. We have always been passingnulltoIOleObject.SetClientSitesince Framework so it is unclear whether or not this method has ever succeeded. The docs seems to indicate that it is ok to passnullpointer so we should investigate what is happening in the windows code and determine next steps to resolve this.Repro (could also use other active x controls):
Once fixed, we should also update our tests that test ActiveX controls to dispose of them properly.