Is there a way to use Debug.WriteLine
in a release build without defining DEBUG
?
You can now debug your release build application. To find a problem, step through the code (or use Just-In-Time debugging) until you find where the failure occurs, and then determine the incorrect parameters or code.
Definition. Writes information about the debug to the trace listeners in the Listeners collection.
By default, Debug includes debug information in the compiled files (allowing easy debugging) while Release usually has optimizations enabled. As far as conditional compilation goes, they each define different symbols that can be checked in your program, but they are language-specific macros.
Diagnostics. Debug. WriteLine will display in the output window ( Ctrl + Alt + O ), you can also add a TraceListener to the Debug.
No, but you can use the Trace
in release by defining TRACE
and using Trace.WriteLine.
Have a look here:
https://support.microsoft.com/en-us/help/815788/how-to-trace-and-debug-in-visual-c
No. If you don't define the DEBUG
preprocessor symbol, any calls to Debug.*
will be removed by the compiler due to the [Conditional("DEBUG")]
attribute being applied.
You might want to consider Trace.WriteLine
or other logging techniques though.
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