Skip to content

Investigate SetClientSite(null) in AxHost.DisposeAxControl #10692

@lonitra

Description

@lonitra

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions