Specifying Environment-Specific Configuration Settings

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

You can use the configuration tools to customize the run-time settings of your configuration to suit a particular environment. This feature is useful if you have multiple environments that share the same basic configuration but require different property settings. For example, you may have a development environment that uses one connection string for the Data Access Application Block and a test environment that uses another.

Instead of maintaining multiple configuration files or having to change a file manually or programmatically, you can create a base configuration file (.config) and a delta file that contains the differences (.dconfig).

To customize a run-time environment

  1. Create a .config file or open an existing one.
  2. Add the appropriate application blocks and configure them.
  3. Right-click Environments, point to New, and then click Environment.
  4. In the right pane, set the properties. The Name property is the name of the environment. The EnvironmentConfigurationFile property is the name of the merged configuration file. The EnvironmentDeltaFile property is the name of the delta file. If you want to encrypt the file, set the ProtectionProvider property by selecting a provider from the drop-down list. Repeat steps 3 and 4 for every environment you want to create.
  5. Click a node whose properties you want to customize. Click in the Overrides on name field, and then click Override Properties.
  6. Set the node's properties.
  7. Repeat steps 5 and 6 for each node you want to customize.
  8. Save the file.
  9. Right-click the environment node name, and then click Save Merged Configuration.

You can also merge your main configuration file and your delta file from the command line. This is useful if you want to use build scripts. To merge the configuration files, you must provide both the main configuration file and the delta file in your command. The following code example shows the syntax.

MergeConfiguration.exe configFiledeltaFile [mergedFile]

The parameters are the following:

  • configFile. This is the main configuration file (.config). It is merged with the delta file.
  • deltaFile. This is the environment delta file (.dconfig). It contains the information that is merged into the main configuration file.
  • mergedFile. Thisis the output file. This file results from merging configFile with deltaFile. If you do not specify the mergedFile, the file name stored in deltaFile is used.

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.
Show: