Hi
I have multiple projects in a solution each one has its own app.config file now i want to make a common place to change the connection string of the final output
How do i do this??
Please help
Thanks
Guruparan
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jan 17, 2012, 3:26 AM
the better idea is to create common poject that handle only database activity.
and this share between all project.
this help to mantain connection string ,code and many other things.
hope this help.
Datta KharadPosted Jan 17, 2012, 12:37 AM
In common app.config file:-
name="appSettings"
type="System.Configuration.AppSettingsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
/>
To access mapped config file
ConfigurationFileMap fileMap = new ConfigurationFileMap(file); //Path to your config file
Configuration configuration = ConfigurationManager.OpenMappedMachineConfiguration(fileMap);
string value = configuration.AppSettings.Settings["key1"].Value;