Thursday, December 01, 2005

Debug and release config files

One of my biggest issues was having certain lines in my config file for working in my developement shop and others for production. Whenever a bug was found or the application was released you would have to swap configs around. After a few years of reading I happened accross this method:


The first paramaeter is the name of the domain property we want to change, and the second is the value.

I have this line in my application as the first line of code to be called

#If DEBUG Then
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "c:\debug.config")
#End If

you can also retreive the data using this:

for a list of items you can use with get/set data look here:

now that I write this posting it looks like the same can be done in a more managed way by using
appDomain.CurrentDomain.SetupInformation.ConfigurationFile = "c:\debug.config"


Post a Comment

<< Home