.NET Framework Class Library
ConfigurationSectionGroupForceDeclaration Method (Boolean)

Forces the declaration for this ConfigurationSectionGroup object.

Namespace:   System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)
Public Sub ForceDeclaration ( _
	force As [%$TOPIC/ms134311_en-us_VS_110_2_0_0_0_0%] _
public void ForceDeclaration(
	[%$TOPIC/ms134311_en-us_VS_110_2_0_1_0_0%] force
void ForceDeclaration(
	[%$TOPIC/ms134311_en-us_VS_110_2_0_2_0_0%] force
member ForceDeclaration : 
        force:[%$TOPIC/ms134311_en-us_VS_110_2_0_3_0_0%] -> unit


Type: SystemBoolean

true if the ConfigurationSectionGroup object must be written to the file; otherwise, false.


The ConfigurationSectionGroup object is the root section group.

- or -

The ConfigurationSectionGroup object has a location.


The ForceDeclaration method forces this ConfigurationSectionGroup declaration to be written to the file if force is true. If force is false, this action might be ignored if the ConfigurationSectionGroup object is required by the system.

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. Also, it can remove a group from a configuration file if the group is not required.

You might want to use the ForceDeclaration method to make a configuration file more portable from one computer to another, without worrying about whether the group declaration already exists.


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

Overloads Shared Sub ForceDeclaration( _
    ByVal sectionGroup _
    As ConfigurationSectionGroup, _
    ByVal force As Boolean)

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

        "Forced declaration for the group: {0} is {1}",
        sectionGroup.Name, force.ToString());
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

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.