From cb1c51a7ef1d741ed5dc513d90ec1891d04e8426 Mon Sep 17 00:00:00 2001 From: gpetrou Date: Fri, 17 May 2019 10:14:08 +0100 Subject: [PATCH] Check if current application is not null in FocusElementManager Current_Exit method --- .../Xceed.Wpf.AvalonDock/Controls/FocusElementManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/Components/Xceed.Wpf.AvalonDock/Controls/FocusElementManager.cs b/source/Components/Xceed.Wpf.AvalonDock/Controls/FocusElementManager.cs index 2d5891d3..4dac1b19 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/Controls/FocusElementManager.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/Controls/FocusElementManager.cs @@ -143,7 +143,9 @@ internal static void SetFocusOnLastElement( ILayoutElement model ) private static void Current_Exit( object sender, ExitEventArgs e ) { - Application.Current.Exit -= new ExitEventHandler( Current_Exit ); + if (Application.Current != null) + Application.Current.Exit -= new ExitEventHandler(Current_Exit); + if( _windowHandler != null ) { _windowHandler.FocusChanged -= new EventHandler( WindowFocusChanging );