From 664009ca09839478b92c7c91da569742d89b471d Mon Sep 17 00:00:00 2001 From: Stephan Rumswinkel <17520641+srwi@users.noreply.github.com> Date: Sat, 7 Sep 2024 23:09:07 +0200 Subject: [PATCH] Fix deskband logging regression --- EverythingToolbar/Helpers/ToolbarLogger.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/EverythingToolbar/Helpers/ToolbarLogger.cs b/EverythingToolbar/Helpers/ToolbarLogger.cs index a97843e6f..5788f4bc5 100644 --- a/EverythingToolbar/Helpers/ToolbarLogger.cs +++ b/EverythingToolbar/Helpers/ToolbarLogger.cs @@ -47,10 +47,15 @@ private static void InitializeExceptionLoggers(ILogger logger) { logger.Error((Exception)args.ExceptionObject, "Unhandled exception"); }; - Application.Current.DispatcherUnhandledException += (sender, args) => + + if (Application.Current != null) { - logger.Error(args.Exception, "Unhandled exception on UI thread"); - }; + // Not applicable for deskband + Application.Current.DispatcherUnhandledException += (sender, args) => + { + logger.Error(args.Exception, "Unhandled exception on UI thread"); + }; + } } private static void ConfigureLogger()