This documentation is archived and is not being maintained.

ConfigurationSectionGroup.ForceDeclaration Method (Boolean)

Note: This method is new in the .NET Framework version 2.0.

Forces the declaration for this ConfigurationSectionGroup object.

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

public void ForceDeclaration (
	bool force
public void ForceDeclaration (
	boolean force
public function ForceDeclaration (
	force : boolean



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

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

The ForceDeclaration method can force a ConfigurationSectionGroup 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 may want to use the ForceDeclaration method to make a configuration file more portable from one machine to another, without warring about if the group declaration already exists.

The following code example shows how to use the ForceDeclaration.

static void ForceDeclaration(
    ConfigurationSectionGroup sectionGroup, 
    bool force)
        "Forced declaration for the group: {0 is {1",
        sectionGroup.Name, force.ToString());

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

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

.NET Framework

Supported in: 2.0