1) To receive notification of a toast using the console or desktop application, your application must have a shortcut in the Start menu.
2) For the application to have a shortcut icon (not a tile icon) in the Windows Start menu, your application must have an AppId. To create an abbreviation for you, you create a new class called ShellHelpers.cs and paste this code into it.
using System; using System.Runtime.InteropServices; using System.Text; using Microsoft.WindowsAPICodePack.Shell.PropertySystem; using MS.WindowsAPICodePack.Internal; namespace DesktopToastsSample.ShellHelpers { internal enum STGM : long { STGM_READ = 0x00000000L, STGM_WRITE = 0x00000001L, STGM_READWRITE = 0x00000002L, STGM_SHARE_DENY_NONE = 0x00000040L, STGM_SHARE_DENY_READ = 0x00000030L, STGM_SHARE_DENY_WRITE = 0x00000020L, STGM_SHARE_EXCLUSIVE = 0x00000010L, STGM_PRIORITY = 0x00040000L, STGM_CREATE = 0x00001000L, STGM_CONVERT = 0x00020000L, STGM_FAILIFTHERE = 0x00000000L, STGM_DIRECT = 0x00000000L, STGM_TRANSACTED = 0x00010000L, STGM_NOSCRATCH = 0x00100000L, STGM_NOSNAPSHOT = 0x00200000L, STGM_SIMPLE = 0x08000000L, STGM_DIRECT_SWMR = 0x00400000L, STGM_DELETEONRELEASE = 0x04000000L, } internal static class ShellIIDGuid { internal const string IShellLinkW = "000214F9-0000-0000-C000-000000000046"; internal const string CShellLink = "00021401-0000-0000-C000-000000000046"; internal const string IPersistFile = "0000010b-0000-0000-C000-000000000046"; internal const string IPropertyStore = "886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99"; } [ComImport, Guid(ShellIIDGuid.IShellLinkW), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IShellLinkW { UInt32 GetPath( [Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath,
Code for creating a shortcut (this code can be added to the same class where you will show the toast)
public bool TryCreateShortcut() { String shortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Microsoft\\Windows\\Start Menu\\Programs\\FixSus Toasts Sample .lnk"; if (!File.Exists(shortcutPath)) { InstallShortcut(shortcutPath); return true; } return false; } private void InstallShortcut(String shortcutPath) {
Now you can create a toast show
APP_ID can be any string. In my case, it was a "NotificationTest.KEY" Note. Do not modify the ShellHelper class. Edit: Follow Evaldas B first, then apply this solution.