Skip to content

MetroWindow OnClosing exception (.Net 4.0) #2476

@gigios

Description

@gigios

It is not clear why but, when I close the main window of my application, I receive an exception because the variable metroActiveDialogContainer is null.
I have checked my code and for each MetroWindow loaded I have the same OnClosing event, but when it is closed the last window I receive an additional OnClosing event where the metroActiveDialogContainer is null.

I have applied this fix (MetroWindow.cs line 782):

var dialog = this.Invoke(() => this.metroActiveDialogContainer?.Children.OfType<BaseMetroDialog>().LastOrDefault());

I have only added a Null-conditional operator (“?.”)

Probably the problem is on my side (I think that there is an hidden window that is loaded and not closed in my code) but I think that this fix can be inserted in the 'official' code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions