How to Loading the Configuration from Alternative Files

Oct 7, 2010 at 7:04 AM
Edited Oct 7, 2010 at 7:14 AM

Hi Guys,

I'm working on a azure project which has two web roles,  these two web role projects have a reference to a BussinessServices project

Currently the configuration is done by using web.config file in each web role project.

Because both web role projects need to use SearchService from the BusinessServices project

Then I have to register SearchService in both web role projects, such as

<register type="BusinessServices.ISearchService, BusinessServices" mapTo="BusinessServices.SearchService, BusinessServices"> 


This information is duplicate in two web.config files, which is not good.

Is here a way that I can extract these common bits into a separate file that both web role projects can reference to.


Thanks in advance



Oct 7, 2010 at 4:01 PM

You can use ConfigurationManager.OpenMappedExeConfiguration load a UnityConfigurationSection from whatever file you want, and then feed that section object to LoadConfiguration.