Best Approach For Configuring Multiple .Net Applications


Best Approach For Configuring Multiple .Net Applications



We have a suite of interlinked .Net 3.5 applications. Some are web sites, some are web services, and some are windows applications. Each app currently has its own configuration file (app.config or web.config), and currently there are some duplicate keys across the config files (which at the moment are kept in sync manually) as multiple apps require the same config value. Also, this suite of applications is deployed across various envrionemnts (dev, test, live etc)

What is the best approach to managing the configuration of these multiple apps from a single configuration source, so configuration values can be shared between multiple apps if required? We would also like to have separate configs for each environment (so when deploying you don't have to manually change certain config values that are environment specific such as conenction strings), but at the same time don't want to maintain multiple large config files (one for each environment) as keeping this in sync when adding new config keys will prove troublesome.

Thanks in advance

Robin




How come classes in subfolders in my App_Code folder are not being found correctly?

1:



Detecting Unsaved Changes
We use file templates such as MyApp.config.template and MyWeb.config.template with NAnt properties for the bits that are different between environments.


Update viewstate after populating a list with ASP.NET AJAX
So the template file might look a bit like this:.
Is buffer overflow/overrun possible in completely managed asp.net c# web application
<MyAppConfig>     <DbConnString>${DbConnString}</DbConnString>     <WebServiceUri uri="${WebServiceUri}" /> </MyAppConfig> 
During a build we generate all the configs for the different environments by just looping through each environment in a NAnt script, changing the value of the NAnt properties ${DbConnString} and ${WebServiceUri} for each environment (in fact these are all set in a single file with sections for each environment), and doing a NAnt copy with the option to expand properties turned on..
Implementing cache correctly in a class library for use in an asp.net application
It took a little while to get set up but it has paid us back at least tenfold in the amount of time saved messing around with different versions of config files.


Server Error in '/' Application
.
Handling Long Running Reports


How can I easily turn a .Net Windows Form app into an Asp.net app using Visual Studio 2005?

2:


Visual Studio has a relatively obscure feature that lets you add existing items as links, which should accomplish what you're looking for.

Check out Derik Whittaker's post on this topic for more detail.. Visual Studio really should make this option more visible.

Nobody really thinks to click on that little arrow next to the "Add" button..


3:


You can split App.config into multiple configuration files.

You just specify the name of the file that contains the config section.. Change app.config:.
<SomeConfigSection>   <SettingA/>   <SettingB/> </SomeConfigSection> <OtherSection>   <SettingX/> </OtherSection> 
Into app.config and SomeSetting.xml:.
<SomeConfigSection file="SomeSetting.xml" /> <OtherSection file="Other.xml" /> 
Where SomeSetting.xml contains: . Now you can compose your app.config from different section files with some sort of build or deploy script.

E.g.:.
if debug copy SomeSettingDebug.xml deploydir/SomeSetting.xml if MySql copy OtherSectionMySql.xml deploydir/OtherSetting.xml 


4:


These 2 questions might help you: Utilizing machine.config and Managing app.config for large projects.


5:


Check out the prism framework from Microsofts patterns and practices group?.



70 out of 100 based on 70 user ratings 670 reviews