diff --git a/src/DiffEngine/Tray/DiffEngineTray.cs b/src/DiffEngine/Tray/DiffEngineTray.cs index 7a265016..8639b860 100644 --- a/src/DiffEngine/Tray/DiffEngineTray.cs +++ b/src/DiffEngine/Tray/DiffEngineTray.cs @@ -17,6 +17,13 @@ static DiffEngineTray() catch (IOException) { } + // A mutex that exists but is not accessible to this caller, which Mutex.TryOpenExisting + // documents: the tray under one account and the tests under another. Uncaught in a static + // constructor it is far worse than a wrong answer - the type never initialises, so every + // later DiffRunner.Launch and AddDelete in the process throws TypeInitializationException + catch (UnauthorizedAccessException) + { + } } public static bool IsRunning { get; internal set; } diff --git a/src/DiffEngine/Tray/TrayDetector.cs b/src/DiffEngine/Tray/TrayDetector.cs index 893e1c6c..d2ae506b 100644 --- a/src/DiffEngine/Tray/TrayDetector.cs +++ b/src/DiffEngine/Tray/TrayDetector.cs @@ -15,6 +15,13 @@ public static bool IsRunning() catch (IOException) { } + // Documented for a mutex that exists but cannot be opened by this caller: the tray running + // under one account and the tests under another in the same session. "Not accessible" is + // not "not running", but from here there is nothing to tell them apart with, and the + // answer that keeps a diff tool launching is the one to take + catch (UnauthorizedAccessException) + { + } return false; }