Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Break the debugger on assertion failed

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.

like image 375
Bogi Avatar asked Jan 28 '11 08:01

Bogi


People also ask

What does debug assertion failed mean?

An assertion statement specifies a condition that you expect to hold true at some particular point in your program. If that condition does not hold true, the assertion fails, execution of your program is interrupted, and this dialog box appears. Click. To. Retry.

How do I fix debug assertion failed Visual C ++?

You may uninstall Microsoft Visual C++ Runtime Package from Program & Features then reinstall it again. Thereafter, check if the issue persists. You may run system file checker [SFC] scan on the computer which will replace the missing or corrupt files & check if the issue persists.

What causes assertion failure?

An assertion failure occurs when the database server cannot continue normal processing and must shut down. You can correct some of the problems that cause assertion failures, such as disk issues. For other problems that cause assertion failures, you must contact IBM® Software Support.

What is assertion failure C++?

An assertion statement specifies a condition that you expect to be true at a point in your program. If that condition is not true, the assertion fails, execution of your program is interrupted, and the Assertion Failed dialog box appears.


2 Answers

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

like image 98
Bogi Avatar answered Sep 21 '22 09:09

Bogi


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

like image 32
Darrel Hoffman Avatar answered Sep 21 '22 09:09

Darrel Hoffman