Skip to main content
.NET Framework Class Library
SectionInformation Class

Contains metadata about an individual section within the configuration hierarchy. This class cannot be inherited.

Inheritance Hierarchy
SystemObject
  System.ConfigurationSectionInformation

Namespace:   System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)
Syntax
Public NotInheritable Class SectionInformation
public sealed class SectionInformation
public ref class SectionInformation sealed
[<[%$TOPIC/ms134738_en-us_VS_110_2_0_3_0_0%]>]
type SectionInformation =  class end

The SectionInformation type exposes the following members.

Properties
  NameDescription
Public property AllowDefinitionGets or sets a value that indicates where in the configuration file hierarchy the associated configuration section can be defined.
Public property AllowExeDefinitionGets or sets a value that indicates where in the configuration file hierarchy the associated configuration section can be declared.
Public property AllowLocationGets or sets a value that indicates whether the configuration section allows the location attribute.
Public property AllowOverrideGets or sets a value that indicates whether the associated configuration section can be overridden by lower-level configuration files.
Public property ConfigSourceGets or sets the name of the include file in which the associated configuration section is defined, if such a file exists.
Public property ForceSaveGets or sets a value that indicates whether the associated configuration section will be saved even if it has not been modified.
Public property InheritInChildApplicationsGets or sets a value that indicates whether the settings that are specified in the associated configuration section are inherited by applications that reside in a subdirectory of the relevant application.
Public property IsDeclarationRequiredGets a value that indicates whether the configuration section must be declared in the configuration file.
Public property IsDeclaredGets a value that indicates whether the associated configuration section is declared in the configuration file.
Public property IsLockedGets a value that indicates whether the associated configuration section is locked.
Public property IsProtectedGets a value that indicates whether the associated configuration section is protected.
Public property NameGets the name of the associated configuration section.
Public property OverrideModeGets or sets the OverrideMode enumeration value that specifies whether the associated configuration section can be overridden by child configuration files.
Public property OverrideModeDefaultGets or sets a value that specifies the default override behavior of a configuration section by child configuration files.
Public property OverrideModeEffectiveGets the override behavior of a configuration section that is in turn based on whether child configuration files can lock the configuration section.
Public property ProtectionProviderGets the protected configuration provider for the associated configuration section.
Public property RequirePermissionGets a value that indicates whether the associated configuration section requires access permissions.
Public property RestartOnExternalChangesGets or sets a value that specifies whether a change in an external configuration include file requires an application restart.
Public property SectionNameGets the name of the associated configuration section.
Public property TypeGets or sets the section class name.
Top
Methods
  NameDescription
Public method Equals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public method ForceDeclarationForces the associated configuration section to appear in the configuration file.
Public method ForceDeclaration(Boolean)Forces the associated configuration section to appear in the configuration file, or removes an existing section from the configuration file.
Public method GetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public method GetParentSectionGets the configuration section that contains the configuration section associated with this object.
Public method GetRawXmlInfrastructure. Returns an XML node object that represents the associated configuration-section object.
Public method GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method ProtectSectionMarks a configuration section for protection.
Public method RevertToParentCauses the associated configuration section to inherit all its values from the parent section.
Public method SetRawXmlInfrastructure. Sets the object to an XML representation of the associated configuration section within the configuration file.
Public method ToStringReturns a string that represents the current object. (Inherited from Object.)
Public method UnprotectSectionRemoves the protected configuration encryption from the associated configuration section.
Top
Remarks

The SectionInformation object contains the metadata about an individual section within the configuration hierarchy. This object can be used in order to validate and change the properties of an individual section.

Examples

The following example shows how to get the SectionInformation metadata that is associated with a ConfigurationSection object.

Public Shared Function GetSectionInformation() _
As SectionInformation

    ' Get the current configuration file. 
    Dim config _
    As System.Configuration.Configuration = _
    ConfigurationManager.OpenExeConfiguration( _
    ConfigurationUserLevel.None)

    ' Get the section. 
    Dim section As UrlsSection = _
    CType(config.GetSection("MyUrls"), UrlsSection)

    Dim sInfo As SectionInformation = _
    section.SectionInformation

    Return sInfo

End Function 'GetSectionInformation
 
static public SectionInformation 
    GetSectionInformation()
{

    // Get the current configuration file.
    System.Configuration.Configuration config =
            ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None);

    // Get the section.
    UrlsSection section =
        (UrlsSection)config.GetSection("MyUrls");


    SectionInformation sInfo = 
        section.SectionInformation;

    return sInfo;

}

The following example is an excerpt of the configuration file that is used by the previous example.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="MyUrls" type="Samples.AspNet.UrlsSection,
      ConfigurationElement, Version=1.0.0.0, Culture=neutral,
      PublicKeyToken=null" allowDefinition="Everywhere"
      allowExeDefinition="MachineToApplication"
      restartOnExternalChanges="true" />
  </configSections>
  <MyUrls name="MyFavorites">
    <simple name="Contoso" url="http://www.contoso.com" port="8080" />
    <urls>
      <clear />
      <add name="Microsoft" url="http://www.microsoft.com" port="0" />
    </urls>
  </MyUrls>
</configuration>
Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

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