Configuration

System and application configuration is managed by XML files with a .config extension. Configuration files exist at both the machine and application level. There is a single machine-level configuration file, located at runtime_install_path \CONFIG\machine.config. For example, C:\WINNT\Microsoft.NET\Framework\v1.0.2914\CONFIG\machine.config. Application-configuration files are optional. When they exist, they reside in the application’s root folder and are named application_file_name .config. For example, myApplication.exe.config. Web application-configuration files are always named web.config. They can exist in the web application’s root folder and in subfolders of the application. Settings in subfolders’ configuration files apply only to pages retrieved from the same folder and its child folders and override settings from configuration files in higher-level folders.

Configuration files should be used for all application-configuration information; the Windows Registry should no longer be used for application settings.

Configuration File Format

Configuration files are XML documents, where the root element is <configuration> . For example:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>
   <!-- More stuff goes in here. -->
</configuration>

To be as flexible as possible, .NET configuration files use a scheme in which the application developer can decide on the names of the subelements within the <configuration> element. This is done using the <configSections> ,

Get Programming Visual Basic .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.