skip to the main content area of this page
Patterns and Practices

 

Enterprise Library External File Configuration Source for Application Block Settings


The configuration needs of Enterprise Library grows and grows with the addition of new application blocks like the Validation Application Block and Policy Injection Application Block. Although it is possible to store the configuration settings of each application block in the application's App.config or Web.config, it starts to become more and more unmanageable to add and modify settings not used with Enterprise Library. As an alternative, it is often useful to create a separate external configuration file, called EntLib.config, that will exclusively hold only the application block configuration settings for Enterprise Library.

In situations where a single external configuration file will hold all Enterprise Library configuration settings, it is best to specify the external configuration source within the application's App.config or Web.config file. The image below shows the results of specifying an external file as a configuration source.

 

Enterprise Library External Configuration File Source

 

This was added by right-clicking on the Web.config file and choosing Configuration Sources.

 

Enterprise Library Configuration Sources

 

A filename of EntLib.config is specified in the Properties Grid. The path can be a relative or absolute path. In this case the EntLib.config file is specified as a relative path and located in the application's root directory along with the Web.config file.

 

Enterprise Library Configuration File Source Properties

 


The end result is a few entries in the application's Web.config file specifying the external configuration file source for Enterprise Library Application Block Settings.

 

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="enterpriseLibrary.ConfigurationSource" type="..." />
  </configSections>
  <enterpriseLibrary.ConfigurationSource selectedSource="External File">
    <sources>
      <add
        name="External File"
        type="..."
        filePath="EntLib.config" />
    </sources>
  </enterpriseLibrary.ConfigurationSource>
</configuration>

 


Tags: EntLibConfigurationEditor


Topics



 

Popular Tags



Recent Links