I am showing a windows 10 toast notification in my c# netcore 3.0 application with following code using https://www.nuget.org/packages/Microsoft.Toolkit.Uwp.Notifications/:
const string _appId = "Windows.SystemToast.Explorer";
var toastContent = new ToastContent
{
Visual = new ToastVisual
{
BindingGeneric = new ToastBindingGeneric
{
Children =
{
new AdaptiveText
{
Text = "Hello",
},
new AdaptiveText
{
Text = "World",
},
},
},
},
};
var doc = new XmlDocument();
doc.LoadXml(toastContent.GetContent());
var toast = new ToastNotification(doc);
ToastNotificationManager.CreateToastNotifier(_appId).Show(toast);
It works fine if I run the app normally:
When the app is started as admin (right click exe: run as administrator) the toast notification does not get shown and an error gets thrown: 0x80070005 (E_ACCESSDENIED)
How can one show toast notifications in applications run as admin?
User contributions licensed under CC BY-SA 3.0