Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug.WriteLine in release build

Tags:

c#

.net

debugging

Is there a way to use Debug.WriteLine in a release build without defining DEBUG?

like image 584
Karsten Avatar asked Mar 24 '11 12:03

Karsten


People also ask

Can you debug a release build?

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.

What does debug WriteLine do?

Definition. Writes information about the debug to the trace listeners in the Listeners collection.

What is difference between release and debug mode?

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.

When you call debug write () to generate debugging messages output is sent to the?

Diagnostics. Debug. WriteLine will display in the output window ( Ctrl + Alt + O ), you can also add a TraceListener to the Debug.


2 Answers

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

like image 136
Nick Avatar answered Sep 23 '22 00:09

Nick


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.

like image 41
Jon Skeet Avatar answered Sep 26 '22 00:09

Jon Skeet