.NET Framework Class Library
ConfigurationSectionGroupForceDeclaration Method

Forces the declaration for this ConfigurationSectionGroup object.

Namespace:   System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)
Syntax
Public Sub ForceDeclaration
public void ForceDeclaration()
public:
void ForceDeclaration()
member ForceDeclaration : unit -> unit
Remarks

The ForceDeclaration method can force a ConfigurationSectionGroup object to be written to a configuration file, even if it is not required because it is already declared in a parent file.

Examples

The following code example shows how to use the ForceDeclaration method.

Overloads Shared Sub ForceDeclaration( _
    ByVal sectionGroup As ConfigurationSectionGroup)

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

        sectionGroup.ForceDeclaration()

        config.Save(ConfigurationSaveMode.Full)

        Console.WriteLine( _
        "Forced declaration for the group: {0}", _
        sectionGroup.Name)
    End Sub 'ForceDeclaration
static void ForceDeclaration(
    ConfigurationSectionGroup sectionGroup)
{

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

    sectionGroup.ForceDeclaration();

    config.Save(ConfigurationSaveMode.Full);

    Console.WriteLine(
        "Forced declaration for the group: {0}",
        sectionGroup.Name);
}
Version Information

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8.1, Windows Server 2012 R2, 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.