Multiple Configuration Sources for Enterprise Library 4.1?
        Posted  
        
            by Martijn B
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Martijn B
        
        
        
        Published on 2010-06-01T11:01:46Z
        Indexed on 
            2010/06/01
            11:03 UTC
        
        
        Read the original article
        Hit count: 468
        
Hi All,
We use the caching and logging application blocks from entlib 4.1. We want to keep the configuration of those two in seperate files. How can we achieve this?
It looks like entlib is always using the selectedSource as it configuration.
I tried the following:
<?xml version="1.0" encoding="utf-8" ?>    
<configuration> 
  <configSections>    
    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9057346a2b2dcfc8" />
  </configSections>
  <enterpriseLibrary.ConfigurationSource selectedSource="messagesCache">    
    <sources>    
      <add name="messagesCache" filePath="Configuration\\messagesCache.config"  type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9057346a2b2dcfc8" />    
      <add name="logging" filePath="Configuration\\logging.config"  type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9057346a2b2dcfc8" />    
    </sources>
  </enterpriseLibrary.ConfigurationSource>    
</configuration>
But this doesn't work because the application blocks always use the selectedSource attribute value.
Any suggestions woulde be welcome!
Gr
Martijn
© Stack Overflow or respective owner