public override void Fail(string message, string detailMessage) { if (ignoreAssertions) { return; } if (Debugger.IsAttached) { core.Fail(message, detailMessage); return; } int result = 0; Application.Current.Dispatcher.Invoke(() => { result = fileSystem.ShowOptions( "Debug Assert!" + versionNumber, message + Environment.NewLine + Environment.NewLine + detailMessage, null, new[] { new VisualOption { Index = 0, Option = "Ignore", ShortDescription = "Don't Show Assertions", Description = "Ignore assertions until the next time the application is opened." }, new VisualOption { Index = 1, Option = "Debug", ShortDescription = "Show Full Message", Description = "Bring up the full dialog with debugging options." }, new VisualOption { Index = 2, Option = "Continue", ShortDescription = "Ignore This One", Description = "Ignore this assertion, but show this dialog again if there's another." }, }); }); // user hit "Ignore Additional Assertions" ignoreAssertions = result == 0; while (result == 1) { if (Debugger.IsAttached) { Debugger.Break(); break; } else { Application.Current.Dispatcher.Invoke(() => { result = fileSystem.ShowOptions( "Attach a Debugger", "Attach a debugger and click 'Debug' to get more information about the following assertion:" + Environment.NewLine + message + Environment.NewLine + detailMessage + Environment.NewLine + "Stack Trace:" + Environment.NewLine + Environment.StackTrace, null, new[] { new VisualOption { Index = 1, Option = "Debug", ShortDescription = "Show in Debugger", Description = "Break in a connected debugger" }, } ); }); } } }