'C# Send a toast notification from a Windows Service : UnauthorizedAccessException
I try to send a Toast Notification in a Windows Service, but I have this exeption :
System.UnauthorizedAccessException: Accès refusé. (Exception de HRESULT : 0x80070005 (E_ACCESSDENIED)) à Windows.UI.Notifications.ToastNotifier.Show(ToastNotification notification)
My service run with the local system account. I tried with my personal account but it's the same.
using Microsoft.Toolkit.Uwp.Notifications;
...
ToastContentBuilder toast = new ToastContentBuilder()
.AddText("My title", hintMaxLines: 1)
.AddText("My text");
toast.Show();
Windows 10, .Net 4.8, C#
Thank you for your help !
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|