Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio - Debug vs Release

I built a windows service, targeted for .NET 2.0 in VS 2008. I run it as a console app to debug it.

Console app is working great. I put it on my local computer as a service, compiled in debug mode, still working great. I'm ready to release now, and suddenly, when I set it to release mode, the service compiles and installs, but nothing happens. (No code in service is running at all).

I realize that the release vs debug mode are property configuration settings, but it seems that in release mode, even when I check define DEBUG constant, uncheck Optimize code, and set Debug info to 'full', it is still doing nothing.

Set it back to debug and it's working like a charm again.

(As a sidenote, I tried resetting the target framework to 3.5 to make sure that wasn't the issue, too)

So my questions (in order of importance) are these:

  1. Will using my "debug" version in any way ever cause any problems?

  2. What settings are different between debug and release besides the three I've been trying to change already?

  3. This seems like a weird error to me and has stirred up my curiosity. Any idea what would cause this?

EDIT: Should mention, I already am using a custom installer. Basically I compile the program (in either debug or release) and then install it with the respective installer.

like image 338
Brandi Avatar asked Jun 29 '10 17:06

Brandi


People also ask

What is the difference between debug and release build?

Debug Mode: In debug mode the application will be slow. Release Mode: In release mode the application will be faster. Debug Mode: In the debug mode code, which is under the debug, symbols will be executed. Release Mode: In release mode code, which is under the debug, symbols will not be executed.

Is debug build faster than release?

The RELEASE build is between 2x - 10x faster than the DEBUG build because all safety checks are disabled, the exact performance difference depends on your game.

Can I debug in release mode Visual Studio?

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 is debug or release?

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.


1 Answers

1) It might, if not directly, so indirectly by making the application slower and making it use more memory.

2) When it runs in debug mode, there are certain things that works differently, for example:

  • The code is compiled with some extra NOP instructions, so that there is at least one instruction at the beginning of each code line, so that it will be possible to place a break point at any line.

  • The instructions can be rearranged in release mode, but not in debug mode, so that the code can be single stepped and the result will correspond to the exact order of the source code.

  • The garbage collector works differently, by letting references survive throughout their entire scope instead of only for the time that they are used, so that variables can be viewed in debug mode without going away before the scope ends.

  • Exceptions contain more information and takes a lot longer to process when thrown.

All those differences are relatively small, but they are actual differences and they may matter in some cases.

If you see a great difference in performance between debug mode and release mode, it's usually because there is something wrong with the code, like for example if it's throwing and catching a huge amount of exceptions. If there is a race condition in the code, it may only happen in release mode because there is some extra overhead in debug mode that makes the code run slightly slower.

3) As to what the problem with your service is, I don't know, but it doesn't seem to be related to how the code is executed in debug mode or release mode. The code would start in any case, and if it was a problem with the code, it would crash and you would be able to see it in the event log.

like image 87
Guffa Avatar answered Oct 16 '22 00:10

Guffa