MMC DisconnectedContext error

136 views Asked by At

I have an issue with a MMC snapin developed using C#. Using the code from Microsoft's MMC sample for an snapin using a property page I have noticed a DisconnectedContext error popping up after displaying a modal messagebox from a property page.

I can reproduce this every time, and I can "fix" it with a bit of a hack.

using the sample code for CanApplyChanges() in the property page's user control, I display a messagebox if there is a validation error:

    public bool CanApplyChanges()
    {
        if (this.password.Text != this.passwordConfirm.Text)
        {
            MessageBoxParameters mbp = new MessageBoxParameters();
            mbp.Text = "Passwords do not match";
            userPropertyPage.ParentSheet.ShowDialog(mbp);
        }
    }

Commenting out this messagebox stops the error. I can change this to display the messagebox parented to the MMC console instead, so (I assume) it doesn't block the property page message pump, but obviously this allows the user to continue interacting with the page which is not the best UI.

Has anyone else seen this problem - I open the property page, cancel it, open it again, make it pop the modal messagebox (using the recommended way of displaying them) when you click the Apply button, then click cancel and re-open the page - I always get the DisconnectedContext error.

I don't do anything fancy in the constructor or RefreshData() methods of my control - I fetch simple data from an EntityFramework object and place it in a few textbox and checkbox controls.

Obviously there is a problem with the thread that show the property sheet interacting badly with the rest of the snapin, but I have no threads of my own, and there is no interaction between my control and the only place I interact with the parent property sheet is to call that ShowDialog method.

Any ideas will be welcomed at this point, as would any information leading to a successful apprehension of the bug!

0

There are 0 answers