When using Trace.Fail()
method, the code execution (either in debug or release) will always halt at this line (226)
if (AutoFlush) listener.Flush();
in TraceInternal.Fail()
method.
It behave just like if there were a breakpoint at this line but it is not my code (it is one of the built-in System.Diagnostics
classes).
I guess this is related to the change I made that was to allow debugger to step into other assembly code, if ever debug symbol were available, in order to ease my library debugging.
Am I missing something here ?
This is normal behavior, the debugger automatically breaks the execution flow when Trace.Fail() is called. This is because the Trace.Fail() method triggers a debugger break, which is often used to provide notification when a problem is detected at runtime. The official documentation does not specify this, but it is indeed the default behavior. If you need to log information without interrupting program execution and use Trace.Fail(), you need to add code before setting up a listener for Trace output: Trace.Listeners.Clear();