consolidating application configuration files..

consolidating application configuration files..

Old forum URL: forums.lhotka.net/forums/t/130.aspx


JCardina posted on Wednesday, May 17, 2006

We have a rather large CSLA app that has grown to the app itself and a dozen add on programs and utilities.  They all use the same exact configuration file settings and currently we instruct users to copy the main applications config file and rename it to the utility or add-on program name depending on which one they purchased or are using.

This is ugly on it's own and particularly when they change their data source or something to say the least.  I'm wondering if there is any reliable method to consolidate those configuration files into one single one "Global.config" or somethign that will work also with asp.net as well as winforms.

I noticed that the new ConfigurationManager class in .net 2.x seems to support opening other config files but I can't make heads or tails of it so far.

Any thoughts or ideas would be very welcome.

Skeeboe replied on Wednesday, May 17, 2006

We modified CSLA to look in a default.config if it can't find an entry in the local app.config. That gives us the ability for each program have a different value for each setting or they can all use the default. I haven't looked into the ConfigurationManager in 2.0 yet.

Jurjen replied on Thursday, May 18, 2006

I usually create a Common.Config with database and other settings.

Then from the various App.Config I refer to this Common.Config, this way you can still use your standard code to retrieve AppSettings values. No additional code needed.

 

App.Config :

<appSettings file="..\Common.Config" />

Or

<appSettings file="..\Common.Config" >

      <add key="MyPath" value="C:\" />

</appSettings

 

Common.Config :

<?xml version="1.0" encoding="utf-8" ?>

<appSettings>
  <add key="DB:Security"     value="....." />
</appSettings>

Hope this helps...
Jurjen.

JCardina replied on Thursday, May 18, 2006

Jurjen:

I usually create a Common.Config with database and other settings.

Then from the various App.Config I refer to this Common.Config, this way you can still use your standard code to retrieve AppSettings values. No additional code needed.

That helps a *lot*!  I didn't know you could do that.

I'll check that out, thank you very much for posting that.

Cheers!

Copyright (c) Marimer LLC