Break the debugger on assertion failed

10,929

Solution 1

Stupid me, the solution was simple. When the window pops out, press pause in debugger :)

Solution 2

Not sure about VS 2008, but in at least 2010 and later, you can go to Debug/Exceptions (Ctrl-Alt-E). Click the "Add" button, choose "Common Language Runtime Exceptions", and type:

Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException

and hit "OK". It will now appear on the list, make sure you check the checkbox in the "Thrown" column. You will now get a break on any assert failure.

Updated: screenshot from VS 2017 AssertFailedException

Solution 3

In addition to Vinay's solution, you can start the debugger for a specific process by calling

Debugger.Break

In your case you could do it every time the listener receives a failure message.

Solution 4

It seems that you can attach the Debugger when assertion fails to see other details - see this article: http://blogs.msdn.com/b/davidklinems/archive/2005/08/29/457847.aspx. Its quite dated but perhaps still applicable.

Share:
10,929
Bogi
Author by

Bogi

Updated on June 19, 2022

Comments

  • Bogi
    Bogi about 2 years

    Is there a way to break the debugger when assertion is false and running the application using Visual Studio debugger. Earlier when I was debugging Windows application I would get an exception and the debugger would break, but now on Smart Device an assertion failed window is showed with stack trace, but I would also like to see variable values etc.