Element not found error while trying to use UserNotficationListener

In a .net console application

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Windows.UI.Notifications.Management;
using Windows.UI.Notifications;
using Windows.Foundation.Metadata;

namespace winrttest5
{
    internal class Program
    {

        static private void Listener_NotificationChanged(UserNotificationListener sender, UserNotificationChangedEventArgs args)
        {
            Console.WriteLine("test");
        }
        static void Main(string[] args)
        {

            UserNotificationListener listener = UserNotificationListener.Current;

            if (!(ApiInformation.IsTypePresent("Windows.UI.Notifications.Management.UserNotificationListener")))
            {
                Console.WriteLine("Listener not supported");
            }

            Console.WriteLine(listener.GetAccessStatus());

            Console.ReadKey();

            listener.NotificationChanged += Listener_NotificationChanged;

        }
    }
}
image.png
Was this page helpful?