I'm trying to use a FileConfigurationSource configuration object to point at a more fully populated configuration file. I'm following the steps given in the help (copied below), but as soon as I "Save" the application file, it overwrites
both the application file and the file I'm creating a FileConfigurationSource reference. This must be a bug; creating an empty configuration file when the whole purpose is to create merely a reference is not at all useful. It even complains
if the existing file is read-only.
Derived from "To use an alternate configuration source "
- Start the Enterprise Library Configuration Console or open the configuration file in the Visual Studio Configuration Editor. To use the Configuration Console, click
Start, point to All Programs, point to Microsoft patterns & practices, point to
Enterprise Library 4.0 – May 2008, and then click
Enterprise Library Configuration.
- On the File menu, click New Application (if you are configuring a new application) or
Open Application (if you are configuring an existing application).
- Right-click the Application Configuration node, point to New, and then click
- Right-click Configuration Sources, point to New, and then click the type of configuration source you want to use (such as
File Configuration Source).
- Use the Properties pane to enter the desired configuration properties for the new configuration source. Specifically, provide the name to an existing configuration file.
- Select the Configuration Sources node, and then select the SelectedSource property in the Properties pane.
- Click the arrow adjacent to System Configuration Source, and then click the configuration source you want to use.
- After you make your configuration changes, click File, and then click
Result: Both the New Application configuration file and the file referred to in step 5 will be overwritten by the Save.
Expect: Only save the New Application configuration file. No useful information can be written to the file referred to in step 5, more likely the file is supposed to exist already.
This behavior is actually by design. The tool is used to author configuration, so it will try to save all configuration -except the
meta-configuration about sources- to the default configuration source. This default source might be even a non-file-based source, so saving is necessary.
You have a valid point in that it should be easier to reuse an existing configuration file, though.