The ConfigurationElement is an abstract class, so it cannot be instantiated. It represents an element within a configuration file.

Note

An element within a configuration file refers to a basic XML element or a section. The basic element is a simple XML tag with related attributes, if any. In its simplest form, a section coincides with a basic element. Complex sections can contain one or more basic elements, a collection of elements, and other sections.

The ConfigurationElement is used as the base class for the classes representing XML configuration elements, for instance ConfigurationSection.

You can extend the ConfigurationElement class to represent a configuration element within a ConfigurationSection section. You can also create a ConfigurationElementCollection collection of ConfigurationElement elements, as shown in the next example.

Handling Configuration. To handle configuration information using the standard types, use one of the following approaches.

Extending Configuration Standard Types. You can also extend the standard configuration types such as ConfigurationElement, ConfigurationElementCollection, ConfigurationProperty, and ConfigurationSection using either a programmatic or a declarative (attributed) model. Refer to the ConfigurationSection class for an example of how to extend a standard configuration type programmatically. Refer to the ConfigurationElement class for an example of how to extend a standard configuration type using the attributed model.

Notes to Implementers
The Configuration is the class that allows programmatic access for editing configuration files. You use one of the open methods provided by WebConfigurationManager for Web applications or by ConfigurationManager for client applications. These methods will return a Configuration object, which in turn provides the required methods and properties to handle the underlying configuration files. You can access these files for reading or writing as explained next.

Reading. You use GetSection or GetSectionGroup to read configuration information. Note the user or process that reads must have the following permissions:

Read permission on the configuration file at the current configuration hierarchy level.

Read permissions on all the parent configuration files.

If your application needs read-only access to its own configuration, it is recommended you use the GetSection overloaded methods in case of Web applications. Or the GetSection method in case of client applications.
These methods provide access to the cached configuration values for the current application, which has better performance than the Configuration class.

Note

If you use a static GetSection method that takes a path parameter, the path parameter must refer to the application in which the code is running, otherwise the parameter is ignored and configuration information for the currently-running application is returned.

Writing. You use one of the Save methods to write configuration information. Note the user or process that writes must have the following permissions:

Write permission on the configuration file and directory at the current configuration hierarchy level.

Read permissions on all the configuration files.

Notes to Inheritors
Every ConfigurationElement object creates an internal ConfigurationPropertyCollection collection of ConfigurationProperty objects that represents either the element attributes or a collection of child elements.
Non-customizable information and functionality is contained by an ElementInformation object provided by the ElementInformation property.
You can use either a programmatic or a declarative (attributed) coding model to create a custom configuration element.

Programmatic Model. This model requires that for each element attribute, you create a property to get and/or set its value and add it to the internal property bag of the underlying ConfigurationElement base class.

Declarative Model. This simpler model, also called the attributed model, allows you to define an element attribute by using a property and then decorate it with attributes. These attributes instruct the ASP.NET configuration system about the property types and their default values. With this information, obtained through reflection, the ASP.NET configuration system creates the element property objects for you and performs the required initialization.