What's the difference between
Debugger.Launch(); Debugger.Break();
?
If a user-mode debugger is attached, the program will break into the debugger. This means that the program will pause and the debugger will become active.
To debug, you need to start your app with the debugger attached to the app process. F5 (Debug > Start Debugging) is the most common way to do that. However, right now you may not have set any breakpoints to examine your app code, so we will do that first and then start debugging.
Debug. Write is only effective on builds where the DEBUG flag is defined, while Trace. Write is only effective when the TRACE flag is defined.
You set breakpoints wherever you want to pause debugger execution. For example, you may want to see the state of code variables or look at the call stack at a certain breakpoint. If you are trying to resolve a warning or issue while using breakpoints, see Troubleshoot breakpoints in the Visual Studio debugger.
Reading the documentation, it sounds like Launch
does nothing if the debugger is attached - it doesn't actually break (although I haven't verified this).
Break
asks to launch the debugger (if not attached), and does do the break.
In reality, it is unlikely you'd have more than one Launch
point... if that.
Launch will start a debugger when one is available. But is just ignored if there is none available. Break will crash the program if no debugger is available.
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