Having a seperate config file for each Block

Topics: Exception Handling Application Block, Logging Application Block
Oct 24, 2008 at 4:54 AM
Hi,

I am using Exception Handling Application Block & Logging Application Block in a web application and my project files are structured such that there are separate class libraries for each Application Block.
So, I have:
  1. Web Application
  2. Exception Helper Class library - includes the configuration for exception handling (app.config) and custom exception handlers etc.
  3. Logging Helper Class Library - includes the configuration for logging (app.config) and custom listeners etc.
The problem is having each helper class have its own configuration file for the block. I cannot find a way to reference it from the web.config of the Web application.

Here is what I did to reference the exception helper class library configuration file through the web.config:

Web.config

    <configSections>
            <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common"/>
    </configSections>

  <enterpriseLibrary.ConfigurationSource selectedSource="File Configuration Source">
    <sources>
      <add name="File Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common" filePath="..\ExceptionHelper\app.config"/>
     </sources>

  </enterpriseLibrary.ConfigurationSource>

This works very well and web.config picks up the configuration for Exception helper class specified at "..\ExceptionHelper\app.config".
But I am having problems in pointing to another file configuration source, for e.g. Logging Helper configuration:

<sources>
      <add name="File Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common" filePath="..\ExceptionHelper\app.config"/>
     
<add name="File Configuration Source 2" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common" filePath="..\LoggingHelper\app.config"/>
</sources>


It throws errors because of File Configuration Source 2 and I cant figure out how to point at 2 configuration files in different locations.

Regards,
Oct 24, 2008 at 5:26 AM
Hi,  I found this page and it may be just what you need. Look at the section for Using Several ConfigurationSources.  
http://blogs.msdn.com/tomholl/archive/2006/04/02/entlib2externalconfig.aspx