diff --git a/tools/JournalBot.Tray/App.xaml.cs b/tools/JournalBot.Tray/App.xaml.cs index e4bda34..174eba8 100644 --- a/tools/JournalBot.Tray/App.xaml.cs +++ b/tools/JournalBot.Tray/App.xaml.cs @@ -33,12 +33,18 @@ public partial class App : Application _tray = new TaskbarIcon { ToolTipText = "JournalBot" }; try { - _tray.Icon = new System.Drawing.Icon( - Path.Combine(AppContext.BaseDirectory, "icon.ico")); + // icon.ico is embedded as a WPF Resource (see .csproj), so load it + // from the resource stream — not the filesystem, which would fail + // because no icon.ico is copied next to the EXE. + var uri = new Uri("pack://application:,,,/icon.ico", UriKind.Absolute); + using var stream = Application.GetResourceStream(uri).Stream; + _tray.Icon = new System.Drawing.Icon(stream); } - catch + catch (Exception ex) { // Missing/corrupt icon must not prevent startup; tray still works. + // Don't swallow silently — a blank tray icon is otherwise a mystery. + System.Diagnostics.Debug.WriteLine($"Tray icon load failed: {ex}"); } _tray.TrayLeftMouseUp += (_, _) => ToggleWindow(); _tray.ContextMenu = BuildMenu();