I stumble upon a weird bug on my desktop application, written in c#, NET 4.5, using Windows Form. I've implemented a simple NotifyIcon system that listen a specific list and, for every item added, it display the title and the description. Pretty straight forward.
It works like a charm during the Debug process, but when I publish the application no notification is shown for whatever reason. Am I missing some particular permission on Windows10?
This is the code of the EventHandler
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
private void OnLogItemAdded(object sender, Utilities.ItemAddedEventArgs args)
{
Event e = (Event)args.item;
switch (e.eventType)
{
case EventType.Info:
MainNotifyIcon.BalloonTipIcon = ToolTipIcon.Info;
break;
case EventType.Error:
MainNotifyIcon.BalloonTipIcon = ToolTipIcon.Error;
break;
case EventType.Warning:
MainNotifyIcon.BalloonTipIcon = ToolTipIcon.Warning;
break;
default:
MainNotifyIcon.BalloonTipIcon = ToolTipIcon.Info;
break;
}
MainNotifyIcon.Visible = true;
MainNotifyIcon.BalloonTipTitle = e.Title;
MainNotifyIcon.BalloonTipText = e.Description;
MainNotifyIcon.ShowBalloonTip(3000);
}
That's it, no other code is involved.
Based on the comment the notification icon should be explicitly set. I did it but still no results. Icon is a resource icon included in the project
MainNotifyIcon.Icon = Properties.Resources.icon;
I ran into the same issue that didn't work in Debug mode either.
If you don't compile your code with "Any CPU" or "x64" and deploy on a Windows 10 64 bits in %ProgramFiles% (not %ProgramFiles(x86)% !) toast notifications will never appear.
However it works in non-64 bits specific folder.
The launch icon created by the .NET publisher creates some kind of shortcut (called an Application Reference) in C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\PUBLISHER\YOUR APP
The notifications don't work when you launch the application using this reference. Not sure why (bug?) but the issue is gone when you launch it using the .exe, you can probably find it somewhere here: C:\Users\USERNAME\AppData\Local\Apps\2.0\ID\ID\ID\YOUR APP.exe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With