views:

175

answers:

2

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.

A: 

I'm not sure I can speak to #1 or #2, but when I've had problems like that, it was because of incorrect threading/concurrency. I'm not sure how large your app is, but that might be a good place to start.

Chad
Chad, while it is always possible that those are valid issues of the OP, I don't think it's likely that those are the problem; it's **much** more likely to be a configuration/install issue
Josh E
It's pretty small, basically one timer that calls one function on it's update. I'm pretty sure thread safety is not it as when the release mode doesn't work, it doesn't even run the constructor, whereas compiling it with the debug settings works flawlessly. Generally sound advice though, thanks. :)
Brandi
+2  A: 

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.

Guffa
Thanks, it seems to work flawlessly and I just went ahead and deployed it that way. I'm still quite confused what's going on, but yeah, it isn't the code. Thanks again. :)
Brandi