ForceDeclaration Method
Collapse the table of content
Expand the table of content

ConfigurationSectionGroup.ForceDeclaration Method ()

 

Forces the declaration for this ConfigurationSectionGroup object.

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

public void ForceDeclaration()

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.

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

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);
}

.NET Framework
Available since 2.0
Return to top
Show:
© 2016 Microsoft