I am not sure of what I'm doing wrong here:
private void MainWindow_OnClosing(object sender, CancelEventArgs e)
{
var ni = new System.Windows.Forms.NotifyIcon
{
Icon = new System.Drawing.Icon("Img/trayicon.ico"),
Visible = true
};
this.Hide();
e.Cancel = true;
}
When the user tries to close the window, MainWindow_OnClosing is triggered via Closing="MainWindow_OnClosing" in the xaml. There, I cancel the closing with e.Cancel = true and attempt to hide the window into a tray icon with the rest of the code above. But all that happens is that the content of the window is filled with a black color and thats it.
Upon clicking the close button the debug console prints out A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll A first chance exception of type 'System.IO.FileNotFoundException' occurred in PresentationFramework.dll
But I am not sure if that has to do anything with it, since I know the icon picture exists within that folder in the project.