diff --git a/Dashboard/App.xaml.cs b/Dashboard/App.xaml.cs
index f920d823..c87d0743 100644
--- a/Dashboard/App.xaml.cs
+++ b/Dashboard/App.xaml.cs
@@ -95,6 +95,16 @@ private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
+ /* Silently swallow Hardcodet TrayToolTip race condition (issue #422).
+ The crash occurs in Popup.CreateWindow when showing the custom visual tooltip
+ and is harmless — the tooltip simply doesn't show that one time. */
+ if (IsTrayToolTipCrash(e.Exception))
+ {
+ Logger.Warning("Suppressed Hardcodet TrayToolTip crash (issue #422)");
+ e.Handled = true;
+ return;
+ }
+
Logger.Error("Unhandled Dispatcher Exception", e.Exception);
MessageBox.Show(
@@ -114,6 +124,16 @@ private void OnUnobservedTaskException(object? sender, UnobservedTaskExceptionEv
e.SetObserved(); // Prevent process termination
}
+ ///
+ /// Detects the Hardcodet TrayToolTip race condition crash (issue #422).
+ ///
+ private static bool IsTrayToolTipCrash(Exception ex)
+ {
+ return ex is ArgumentException
+ && ex.Message.Contains("VisualTarget")
+ && ex.StackTrace?.Contains("TaskbarIcon") == true;
+ }
+
private void CreateCrashDump(Exception? exception)
{
try
diff --git a/Dashboard/Services/NotificationService.cs b/Dashboard/Services/NotificationService.cs
index 5e30b333..e174f311 100644
--- a/Dashboard/Services/NotificationService.cs
+++ b/Dashboard/Services/NotificationService.cs
@@ -44,7 +44,10 @@ public void Initialize()
bool HasLightBackground = Helpers.ThemeManager.HasLightBackground;
- /* Custom tooltip styled to match current theme */
+ /* Custom tooltip styled to match current theme.
+ Note: Hardcodet TrayToolTip can rarely trigger a race condition in Popup.CreateWindow
+ that throws "The root Visual of a VisualTarget cannot have a parent." (issue #422).
+ The DispatcherUnhandledException handler silently swallows this specific crash. */
_trayIcon.TrayToolTip = new Border
{
Background = new SolidColorBrush(HasLightBackground
diff --git a/Lite/App.xaml.cs b/Lite/App.xaml.cs
index bf9c405d..8cc53c40 100644
--- a/Lite/App.xaml.cs
+++ b/Lite/App.xaml.cs
@@ -324,6 +324,16 @@ private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
+ /* Silently swallow Hardcodet TrayToolTip race condition (issue #422).
+ The crash occurs in Popup.CreateWindow when showing the custom visual tooltip
+ and is harmless — the tooltip simply doesn't show that one time. */
+ if (IsTrayToolTipCrash(e.Exception))
+ {
+ AppLogger.Warn("Dispatcher", "Suppressed Hardcodet TrayToolTip crash (issue #422)");
+ e.Handled = true;
+ return;
+ }
+
AppLogger.Error("Dispatcher", "Unhandled exception", e.Exception);
AppLogger.Flush();
@@ -344,6 +354,16 @@ private void OnUnobservedTaskException(object? sender, UnobservedTaskExceptionEv
e.SetObserved(); /* Prevent process termination */
}
+ ///
+ /// Detects the Hardcodet TrayToolTip race condition crash (issue #422).
+ ///
+ private static bool IsTrayToolTipCrash(Exception ex)
+ {
+ return ex is System.ArgumentException
+ && ex.Message.Contains("VisualTarget")
+ && ex.StackTrace?.Contains("TaskbarIcon") == true;
+ }
+
private static string FormatExceptionDetails(Exception? ex)
{
if (ex == null) return "Unknown error";
diff --git a/Lite/Services/SystemTrayService.cs b/Lite/Services/SystemTrayService.cs
index a54bfc19..8c1968b5 100644
--- a/Lite/Services/SystemTrayService.cs
+++ b/Lite/Services/SystemTrayService.cs
@@ -45,7 +45,10 @@ public void Initialize()
bool HasLightBackground = Helpers.ThemeManager.HasLightBackground;
- /* Custom tooltip styled to match current theme */
+ /* Custom tooltip styled to match current theme.
+ Note: Hardcodet TrayToolTip can rarely trigger a race condition in Popup.CreateWindow
+ that throws "The root Visual of a VisualTarget cannot have a parent." (issue #422).
+ The DispatcherUnhandledException handler silently swallows this specific crash. */
_tooltipText = new TextBlock
{
Text = "Performance Monitor Lite",