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:

AppDomain.CurrentDomain.SetData()

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:
appDomain.CurrentDomain.GetData("APP_CONFIG_FILE")

for a list of items you can use with get/set data look here:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2004OCT.1033/cpref/html/frlrfsystemappdomainclassgetdatatopic.htm

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"

0 Comments:

Post a Comment

<< Home