Partager via


Applying a Common Configuration Structure for Applications

If you add a configuration source to your application configuration and specify that this configuration source is the parent source, Enterprise Library will read the contents of this configuration source and merge any local configuration settings you have specified with this parent configuration. Effectively, it inherits the shared configuration and then applies the local settings to override any that occur in both configurations. You can use the configuration tool to specify a parent configuration that will be inherited.

To inherit a shared configuration structure and settings from another configuration source

  1. On the taskbar, click Start, point to All Programs, point to Microsoft patterns & practices, point to Enterprise Library 5.0, point to Enterprise Library Configuration, and then select the version of the configuration editor you require. Alternatively, right-click on a configuration file in Visual Studio Solution Explorer and click Edit Enterprise Library V5 Configuration.

  2. On the Blocks menu click Add Configuration Settings.

  3. In the Sources pane click the plus-sign icon, point to Add Sources and then click the type of configuration source you want to add to the configuration. This is the configuration source from which you will inherit configuration information. In this example, we add a File-based Configuration Source.

    Ff664376.985ebd78-52ad-4662-91fc-b43557df60a1(en-us,PandP.50).png

  4. Set the properties of the configuration source you added. For example, enter the desired File Path property for the new configuration source by typing the path and file name or by clicking the ellipses (...) button and navigating to the file.

    Ff664376.50d30ea1-6687-4a9d-9d7f-1a9d0d045ce9(en-us,PandP.50).png

  5. Click the Configuration Sources property expander chevron to open the properties pane for the section. Set the Parent Source property to the configuration source whose settings you want to inherit.

    Ff664376.a50c0368-547b-4698-b3f0-0b98174875e3(en-us,PandP.50).png

  6. Click Save or Save As on the File menu to save your configuration.

Settings in the inherited configuration source will apply to your application unless you override them by configuring the same setting in your local configuration. For information about how settings are inherited and merged, see Merge Rules for Inherited Configuration.