Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug vs. release in .NET

Tags:

c#

.net

asp.net

Continuing from my previous question, is there a comprehensive document that lists all available differences between debug and release modes in a C# application, and particularly in a web application?

What differences are there?

like image 788
MichaelT Avatar asked Sep 18 '08 08:09

MichaelT


People also ask

What is the difference between debug and release in C#?

The biggest difference between these is that: In a debug build the complete symbolic debug information is emitted to help while debugging applications and also the code optimization is not taken into account. While in release build the symbolic debug info is not emitted and the code execution is optimized.

What is debug and release in Visual Studio?

Visual Studio projects have separate release and debug configurations for your program. You build the debug version for debugging and the release version for the final release distribution. In debug configuration, your program compiles with full symbolic debug information and no optimization.

Is release build faster than debug?

Lots of your code could be completely removed or rewritten in Release mode. The resulting executable will most likely not match up with your written code. Because of this release mode will run faster than debug mode due to the optimizations.

What is the difference between a debug build and a release build?

Major differences are the debug apk and the release apk: For debug builds the apk will be signed with the default debug signing keys with debug flag enabled. For release apk you will have to explicitly specify the apk to sign with and the debug flag will be turned off so that it cannot be debugged.


2 Answers

"Debug" and "Release" are just names for predefined project configurations defined by Visual Studio.
To see the differences, look at the Build Tab in Project Properties in Visual Studio.

The differences in VS2005 include:

  • DEBUG constant defined in Debug configuration

  • Optimize code enabled in Release configuration

as well as other differences you can see by clicking on the "Advanced" button

But you can:

  • Change the build settings for Debug and Release configurations in Project Propeties / Build

  • Create your own custom configurations by right-clicking on the solution in Solution Explorer and selecting Configuration Manager

I think the behaviour of the DEBUG constant is fairly clear (can be referenced in the #if preprocessor directive or in the ConditionalAttribute). But I'm not aware of any comprehensive documentation on exactly what optimizations are enabled - in fact I suspect Microsoft would want to be free to enhance their optimizer without notice

like image 184
Joe Avatar answered Sep 28 '22 03:09

Joe


I'm not aware of one concise document, but:

  • Debug.Write calls are stripped out in Release
  • In Release, your CallStack may look a bit "strange" due to optimizations, as outlined by Scott Hanselman
like image 21
Michael Stum Avatar answered Sep 28 '22 05:09

Michael Stum