I'm using a library which attempts to do Debug.Assert when I do a certion thing, is there anyway to stop it from using Debug.Assert?
Disable assert in C++ One way to disable the assertions is by searching for the assert macro in code after the debugging is completed and removing it manually. A better approach is to disable it using the NDEBUG macro.
In Visual Studio, go to Debug / Windows / Exception Settings. In the Exception Settings, go to Win32 Exceptions / 0xc0000420 Assertion Failed. Uncheck the box in front of that entry.
Assert(Boolean) Checks for a condition; if the condition is false , displays a message box that shows the call stack. Assert(Boolean, Debug+AssertInterpolatedStringHandler) Checks for a condition; if the condition is false , outputs a specified message and displays a message box that shows the call stack.
The Assert method is available only in Visual Basic; the Debug object in the VBA development environment doesn't support the Assert method. Assert is typically used when debugging to test an expression that should evaluate to True. If it doesn't, the Immediate window can be used to investigate why the test failed.
If you can recompile the library, then Marc is correct; just recompile it without DEBUG defined and all the assertions will disappear.
If you can't do that, because say you don't have the source code of the library, then you can have your program clear out the Trace Listeners. That way when the assertion fires, it still fires but it does nothing. (When an assertion fires, it just checks to see what trace listeners are registered, and informs them about the assertion. No listeners means nothing happens.)
In that scenario you might consider replacing the default trace listener with a customer trace listener of your own that does something like logs the assertion to a file. That way you can review the log and see what assertions would have popped up in the "normal" execution of the debug version of the library.
If you compile it without the DEBUG
symbol defined, then no calls to Debug.Assert
will be compiled (the methods are defined with [Conditional("DEBUG")]
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With