Configuration Class

 

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

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

System.Object
  System.Configuration.Configuration

[<Sealed>]
type Configuration = class end

NameDescription
System_CAPS_pubpropertyAppSettings

Gets the AppSettingsSection object configuration section that applies to this Configuration object.

System_CAPS_pubpropertyAssemblyStringTransformer

Specifies a function delegate that is used to transform assembly strings in configuration files.

System_CAPS_pubpropertyConnectionStrings

Gets a ConnectionStringsSection configuration-section object that applies to this Configuration object.

System_CAPS_pubpropertyEvaluationContext

Gets the ContextInformation object for the Configuration object.

System_CAPS_pubpropertyFilePath

Gets the physical path to the configuration file represented by this Configuration object.

System_CAPS_pubpropertyHasFile

Gets a value that indicates whether a file exists for the resource represented by this Configuration object.

System_CAPS_pubpropertyLocations

Gets the locations defined within this Configuration object.

System_CAPS_pubpropertyNamespaceDeclared

Gets or sets a value indicating whether the configuration file has an XML namespace.

System_CAPS_pubpropertyRootSectionGroup

Gets the root ConfigurationSectionGroup for this Configuration object.

System_CAPS_pubpropertySectionGroups

Gets a collection of the section groups defined by this configuration.

System_CAPS_pubpropertySections

Gets a collection of the sections defined by this Configuration object.

System_CAPS_pubpropertyTargetFramework

Specifies the targeted version of the .NET Framework when a version earlier than the current one is targeted.

System_CAPS_pubpropertyTypeStringTransformer

Specifies a function delegate that is used to transform type strings in configuration files.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetSection(String)

Returns the specified ConfigurationSection object.

System_CAPS_pubmethodGetSectionGroup(String)

Gets the specified ConfigurationSectionGroup object.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodSave()

Writes the configuration settings contained within this Configuration object to the current XML configuration file.

System_CAPS_pubmethodSave(ConfigurationSaveMode)

Writes the configuration settings contained within this Configuration object to the current XML configuration file.

System_CAPS_pubmethodSave(ConfigurationSaveMode, Boolean)

Writes the configuration settings contained within this Configuration object to the current XML configuration file.

System_CAPS_pubmethodSaveAs(String)

Writes the configuration settings contained within this Configuration object to the specified XML configuration file.

System_CAPS_pubmethodSaveAs(String, ConfigurationSaveMode)

Writes the configuration settings contained within this Configuration object to the specified XML configuration file.

System_CAPS_pubmethodSaveAs(String, ConfigurationSaveMode, Boolean)

Writes the configuration settings contained within this Configuration object to the specified XML configuration file.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

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 logical entity can exist on the local computer or on a remote server. For information about configuration files, see Configuring Apps by using 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 the following classes:

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.

  • 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".

System_CAPS_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 class provides programmatic access for editing configuration files. You use one of the "Open" methods provided by the WebConfigurationManager class for Web applications or by the ConfigurationManager class for client applications. These methods return a Configuration object, which in turn provides the methods and properties that handle the underlying configuration files. You can access these files for reading or writing configuration 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 method overloads for Web applications. For client application, use the GetSection method.

These methods provide access to the cached configuration values for the current application, which has better performance than the Configuration class.

System_CAPS_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.

.NET Framework
Available since 2.0

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

Return to top
Show: