Notification icon or tray icon is supported for .NET Core 3.0 onwards only. Install .NET Core 3.0 Preview from https://dotnet.microsoft.com/download/dotnet-core/3.0 to add the tray icon for a console or windows application.
Once installed, create a new console application using .NET Core in Visual Studio
Add references to System.Windows.Forms and System.Drawing.Common from .NET Core 3.0 library, which will be located at C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\3.0.0-preview3-27504-2.
Also, add your tray icon. Here, I have used the cat.ico for the tray icon.
In your program, use the NotifyIcon from System.Windows.Forms namespace to create a tray icon and add the notification message to it.
Sample code:
Console.WriteLine(“Hello Kitten!”);
NotifyIcon icon = new NotifyIcon();
icon.Icon = new System.Drawing.Icon(“./cat.ico”);
icon.Visible = true;
icon.BalloonTipText = “Hello from My Kitten”;
icon.BalloonTipTitle = “Cat Talk”;
icon.BalloonTipIcon = ToolTipIcon.Info;
icon.ShowBalloonTip(2000);
Console.Read();
Ensure that the cat.ico will be copied to your output directory
Run the application and observe the tray icon and notification appearing near the task bar.
Doesn’t work for a console app.