Windows Toast Notification throws 0x80070005 (E_ACCESSDENIED) when running as admin

0

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:

enter image description here

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?

c#
winforms
windows-10
windows-community-toolkit
asked on Stack Overflow Mar 8, 2019 by Jenny

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0