What is the difference between Release and Debug modes in Visual Studio? [duplicate]
Asked Answered
C

3

149

Possible Duplicate:
Debug vs. release in .NET
Debug/Release difference

What is the difference between Release and Debug modes in Visual Studio while building a project?

Cardioid answered 1/6, 2009 at 6:30 Comment(1)
This related question has a lot of good info.Rummy
T
110

Well, it depends on what language you are using, but in general they are 2 separate configurations, each with its own settings. 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.

Thruway answered 1/6, 2009 at 6:36 Comment(0)
O
143

Debug and Release are just labels for different solution configurations. You can add others if you want. A project I once worked on had one called "Debug Internal" which was used to turn on the in-house editing features of the application. You can see this if you go to Configuration Manager... (it's on the Build menu). You can find more information on MSDN Library under Configuration Manager Dialog Box.

Each solution configuration then consists of a bunch of project configurations. Again, these are just labels, this time for a collection of settings for your project. For example, our C++ library projects have project configurations called "Debug", "Debug_Unicode", "Debug_MT", etc.

The available settings depend on what type of project you're building. For a .NET project, it's a fairly small set: #defines and a few other things. For a C++ project, you get a much bigger variety of things to tweak.

In general, though, you'll use "Debug" when you want your project to be built with the optimiser turned off, and when you want full debugging/symbol information included in your build (in the .PDB file, usually). You'll use "Release" when you want the optimiser turned on, and when you don't want full debugging information included.

Onus answered 2/6, 2009 at 9:33 Comment(6)
The project configurations can be edited by right clicking on a project in the SolutionExplorer and choosing Properties from the context menu. In order to edit the debugging settings for the project configuration "Release", select the tab "Debug" on the left side and select "Release" with the combo box called "Configuration". =>Using the label "Debug" for a solution configuration or project configuration might be misleading since the "Release" configuration can also be debugged.Gurdwara
Also see following question on how to enable/disable compile optimization. #1199704 (In VB.NET it can be found on the Compile tab => Advanced Compile Options...)Gurdwara
If you want to disable the creation of debugging information for release mode you can do so by setting the option "Generate debug info" to None. Nevertheless the debugger will be attached when starting the application. In order to even avoid that ... you need to use "Start without debugging" (Strg+F5).Gurdwara
We can select which config we use before publishing (Release, Debug, etc.). What about debugging the application? I mean, when running the app in VS, I am expecting that if I select Debug, it will use debug config, and if I select Release and run the app, it will use release config, but as far as I see it does not. Is it normal?Futurity
1) What about the following issues? There are 3 configs in an ASP.NET MVC project: base (web), debug (web.debug), release (web.release). Assume we set debug and release connection string by transformation to the corresponding config (debug and release). When publishing, we can publish according to our selection in the publish dialog. But, when running application, despite I select Debug, it uses release config (bacause I set debug config in base and debug config), is that normal?Futurity
2) When running the application in Debug or Release mode, does VS use base web config or corresponding web config (web.debug.confg or web.release.config)?Futurity
T
110

Well, it depends on what language you are using, but in general they are 2 separate configurations, each with its own settings. 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.

Thruway answered 1/6, 2009 at 6:36 Comment(0)
U
20

The main difference is when compiled in debug mode, pdb files are also created which allow debugging (so you can step through the code when its running). This however means that the code isn't optimized as much.

Uranology answered 1/6, 2009 at 6:35 Comment(4)
You can step through the code in release mode too.Lubricious
pdb files are generated in release mode tooOutcast
-1: This is wrong: pdb files should be generated for release build too, since it's very useful to debug a remotely crashing application and doesn't really add an heavy performance cost. In fact it is the default in VSPilgrimage
Can I assume this that if we are test running the app, Debug mode is essential and for final built Release mode is recommended?Antinode

© 2022 - 2024 — McMap. All rights reserved.