Ok, enough of the house posts! (Well, until tomorrow!) Back to the some programming…
One of the ‘new’ features of .NET 2.0 is the new application settings. This is a really powerful feature for handling application and user-based settings. Some of the main things that used to drive me crazy in .NET 1.1 were addressed, including making it easier to have settings files associated with libraries as well as applications, having a concrete reference to the setting instead of needing to use a string, and having a default value even if the .config file doesn’t exist.
Now, what I’m going to talk about today is how do you override the darn settings! In the application I am developing, we have libraries that use these new Settings properties. That works GREAT, until you need to override the value in another library or the main application. Then, things seem to crash and burn. I was always getting the default value that was set in the libraries Settings.cs file.
It turns out that it is VERY easy to set these. In the main project, or library that you want to override the settings, all one has to do is select the pieces that are in the original app.config file and copy them to the main project or library’s app.config file. Then just change the value, but LEAVE THE NAME THE SAME. This will allow it to override correctly!