From: Dom on 27 Mar 2010 18:35
I thought there was a property that let's me know when I am in a debug
configuration, instead of a Release Configuration. I need it because
I want to use a test database in debug, but a real database in
Is there such a property? I tried
System.Diagnostic.debugger.IsAttached, but that seems to be something
From: Peter Duniho on 27 Mar 2010 18:46
> I thought there was a property that let's me know when I am in a debug
> configuration, instead of a Release Configuration. I need it because
> I want to use a test database in debug, but a real database in
I would advise against doing it that way.
> Is there such a property? I tried
> System.Diagnostic.debugger.IsAttached, but that seems to be something
The easiest way I know of is to use "#if DEBUG" in your code to
conditionally compile code you want in the Debug configuration.
I'm pretty sure there is some information in the assembly somewhere you
could also look for; some kind of optimization setting is kept, that
controls whether the JIT compiler optimizes the program at run-time.
But I don't know specifically what that is.
That said, my previous point about not using the build configuration to
determine what database you are using is based on the fact that you will
need to be able to debug the configuration you expect to use when the
program is deployed, _and_ you also want to make sure you do testing
with the test database with the Release build configuration.
On top of all that, I don't think it's generally a good idea to
hard-code the database reference in your program in the first place,
which would be implied by having the database used depend on the build
So, instead you should make your program so that it allows the user to
configure the database it will use, and then make sure you test all the
combinations of build configuration and database that are relevant.