I'm trying to create windows toast notifications from a console app.
This is fairly straightforward to do in a UWP app but is very difficult in a console app.
I'm getting an exception when I try to display the toast:
System.Exception: 'Element not found. (Exception from HRESULT: 0x80070490)'
My question is: What steps need to be taken to allow me to use notifications from the console app?
Here is my complete code:
using Windows.UI.Notifications;
namespace consoleToast
{
class Program
{
static void Main(string[] args)
{
Windows.Data.Xml.Dom.XmlDocument doc = new
Windows.Data.Xml.Dom.XmlDocument();
doc.LoadXml(xml);
var toast = new ToastNotification(doc)
{
Tag = "18365",
Group = "wallPosts"
};
ToastNotificationManager.CreateToastNotifier().Show(toast);
}
static string xml = @"<toast launch=""app-defined-string""> <visual> <binding template=""ToastGeneric""> </binding> </visual> <actions> </actions> <audio src=""ms-winsoundevent:Notification.Reminder""/> </toast>"; } }
User contributions licensed under CC BY-SA 3.0