From 789a5697060cc2f6f21d71bcf2b9fc6ae08a379a Mon Sep 17 00:00:00 2001 From: Jens Glathe Date: Fri, 23 May 2025 14:55:54 +0200 Subject: [PATCH] fix: handle picky Win11 ToastNotificationService (#487) --- .../ToastNotificationService.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Greenshot.Plugin.Win10/ToastNotificationService.cs b/src/Greenshot.Plugin.Win10/ToastNotificationService.cs index b9120fee7..52005356c 100644 --- a/src/Greenshot.Plugin.Win10/ToastNotificationService.cs +++ b/src/Greenshot.Plugin.Win10/ToastNotificationService.cs @@ -95,7 +95,17 @@ namespace Greenshot.Plugin.Win10 } // Prepare the toast notifier. Be sure to specify the AppUserModelId on your application's shortcut! - var toastNotifier = ToastNotificationManagerCompat.CreateToastNotifier(); + Microsoft.Toolkit.Uwp.Notifications.ToastNotifierCompat toastNotifier = null; + try + { + toastNotifier = ToastNotificationManagerCompat.CreateToastNotifier(); + } + catch (Exception ex) + { + Log.Warn("Could not create a toast notifier.", ex); + + return; + } // Here is an interesting article on reading the settings: https://www.rudyhuyn.com/blog/2018/02/10/toastnotifier-and-settings-careful-with-non-uwp-applications/ try