Is there a way, in code, to determine what "Solutions Configuration" you are running in? For example, 'Debug' vs. 'Release?
I have a service that I like to test in the IDE in Debug, right now I have bool that I set which either runs the 'service' if set to true (which then uses the OnStart method to run my 'main' method), if it's set to false I just run the 'main' method. This works great but I often forget to reset the bool after testing and then when I go to install the service it fails and I have to go back, reset the bool, recompile etc.
If I could just determine programatically that I was running in the IDE in Debug then I could get around this issue.
Edit: While thinking this through, I guess what I really need in the end is to determine if I'm in the 'playing' the app in the ide and not the soulutions configuration. This would allow me to compile in either debug or other configuration.
The simpliest solution seems to check 'System.Diagnostics.Debugger.IsAttached'
You can't directly look at the solution configuration, but you can use a few clues to "guess" what version you are in. For instance, the DEBUG preprocessor macro will only be defined in the Debug solution configuration for C#.
Off the top of my head, you could also add a post-build event to copy in a config file:
...then access the config file during the run. This isn't tied to the code build itself though.
To determine whether you are running under debug in the IDE, look at the
Debugger
class, specifically theIsAttached
property...