Split configuration file into multiple files
We have three ways to split a large configuration file into multiple small configuration files. Here is the introductions.
- <linkedConfiguration>
The main limitation of this way is the <linkedConfiguration> element is not supported for applications with Windows side-by-side manifests. We can refer to MSDN to get more information.
- System.Configuration.ConfigurationManager or System.Web.Configuration.WebConfigurationManager
The main defect is we must design an architecture by ourself for supporting this. We can refer to MSDN to get more information.
- Using configSource
Base on my understanding, this is the best way, we can avoid the previous two defects by the way. Here is my example. I use Unity Application Block of Microsoft Enterpriese Library in the example; I separated unity configuration file into another file under a sub folder.
Code
Web.config (Partial)
Unity.config