From 5b40d2c0beb96689f2c14ff65b4b934ec44e7000 Mon Sep 17 00:00:00 2001 From: Jens Glathe Date: Thu, 20 Apr 2023 22:34:39 +0200 Subject: [PATCH] fix: handle picky Win11 ToastNotificationService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Exception: System.InvalidOperationException Message: Failed initializing notifications --- InnerException: --- Exception: System.IO.IOException Message: Ein dauerhafter Unterschlüssel kann nicht unter einem temporären übergeordneten Schlüssel erstellt werden. Signed-off-by: Jens Glathe --- .../ToastNotificationService.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Greenshot.Plugin.Win10/ToastNotificationService.cs b/src/Greenshot.Plugin.Win10/ToastNotificationService.cs index b9120fee7..91bfa12cf 100644 --- a/src/Greenshot.Plugin.Win10/ToastNotificationService.cs +++ b/src/Greenshot.Plugin.Win10/ToastNotificationService.cs @@ -95,7 +95,16 @@ 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("Ignoring exception as this means that it was not possible to 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