Combining multiple config files in Visual Studio

放肆的年华 提交于 2019-12-04 19:25:36


I have a solution in Visual Studio 2008 which contains multiple C# projects. Each project has it's own config file (App.config and Settings.settings). This makes sense architecturally as each module is autonomous and is used in a number of different solutions.

My problem is that when I compile the solution only the config file for the startup project (or project containing the executable) is included. For other modules the config settings are compiled into the DLL. So my question is, is there any way in Visual Studio of combining multiple config files, or linking them so that settings for DLLs can be changed at runtime?


I'm not sure if this is what you are looking for or if it will help but just as a lead into an area to explore, note that you can link two Config files. For example, I have my connection string in a separate file so my connectionStrings line in Web.config reads:

<connectionStrings configSource="WebCS.config"/>

Then, in the separate file, I have:

    <add name="BSDIConnString" 
         connectionString="Data Source=XXX;Initial Catalog=XXX;User ID=XXX;Password=XXX" 


I don't believe there is. But just in case you're unaware.


OK good people, all you will ever need to know about VS config files:


After more digging, I found this quite useful post

Just in case anyone runs into the same issue, the above seems to be the most practical way of getting around it. Although beware that with this solution creating setup packages may become tedious: