2

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?

Jenny
  • 572
  • 4
  • 16
  • Do you have the proper permissions to run the app as an administrator? (Dumb question, bit figured it wouldn't hurt just to double check) :) – Jaskier Mar 08 '19 at 21:02
  • @Symon: Yes, I am logged in as normal user and right click to run it as my other user account with administrator rights. – Jenny Mar 09 '19 at 06:10

0 Answers0