Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Configuration Class
Collapse the table of content
Expand the table of content

Configuration Class

Updated: May 2010

Represents a configuration file applicable to a particular computer, application, or resource. This class cannot be inherited.

Namespace:  System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)

public ref class Configuration sealed

Configuration settings are stored in a hierarchy of configuration files. The Configuration class instance represents the merged view of the configuration settings from all of the configuration files that apply to a specific physical entity, such as a computer, or to a logical entity, such as an application, or a Web site. The specified logical entity can exist on the local computer or on a remote server. For information about configuration files, see Configuration Files and ASP.NET Configuration Files.

When no configuration file exists for a specified entity, the Configuration object represents the default configuration settings as defined by the Machine.config file.

You can get a Configuration object by using one of the open configuration methods as defined by the following classes:

To generate a configuration file representing the inherited configuration settings for a specified entity, use one of the save-configuration methods:

The The names of the methods that return a Configuration object begin with "Open".

You can also generate a configuration file that represents the configuration settings in a Configuration object. To do this, use one of the following methods:

  • Call the Save method to create a new configuration file.

  • The Call the SaveAs method to generate a new configuration file at another location.

The names of the methods that create configuration files begin with "Save".

NoteNote:

To enable access to configuration settings on a remote computer, use the Aspnet_regiis command-line tool. For more information about this tool, see ASP.NET IIS Registration Tool (Aspnet_regiis.exe). For information about creating and accessing custom configuration settings other than the intrinsic sections included in the .NET Framework, refer to ConfigurationSection.

Notes to Implementers:

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

You use the GetSection method or the GetSectionGroup method to read configuration information. Note that 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 that you use the GetSection overloaded methods in case ofmethod overloads for Web applications. OrFor client application, use 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.

NoteNote:

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.

You use one of the Save methods to write configuration information. Note that 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.

The following code example demonstrates how to use the Configuration class to access configuration-file elements.

No code example is currently available or this language may not be supported.

System::Object
  System.Configuration::Configuration

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Date

History

Reason

May 2010

Rewrote remarks to make them clearer.

Customer feedback.

Community Additions

ADD
Show:
© 2015 Microsoft