Detect build config

  • Thread starter Thread starter ThatsIT.net.au
  • Start date Start date
T

ThatsIT.net.au

Is it possible to detect the build config via code.
I want to run a program with a different connection string when in debug
config

any ideas?
 
public static class Settings
{
public static string ConnectionString
{
get
{
#if DEBUG
return "debug connection string";
#else
read it from the app.config file
#endif
}
}
}
 
ThatsIT.net.au said:
Is it possible to detect the build config via code.

/Any/ Configuration - not that I know of. (You're /not/ just limited to
Debug and Release.)
I want to run a program with a different connection string when in debug
config

Now; is that just /built/ with the Debug Configuration ...

sConnection = ...

#If DEBUG Then
sConnection = ... ' Debug-only settings
#End if

.... or any time you're actively debugging the code?

sConnection = ...

If System.Diagnostics.Debugger.IsAttached Then
sConnection = ... ' Debug-only settings
End if

(Or combine the two, for even greater safety).

HTH,
Phill W.
 
Back
Top