This documentation is archived and is not being maintained.

ConfigurationSection.GetRuntimeObject Method

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

Returns a custom object when overridden in a derived class.

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

protected internal virtual Object GetRuntimeObject ()
protected Object GetRuntimeObject ()
protected internal function GetRuntimeObject () : Object

Return Value

The object representing the section.

When the GetSection method is called at run time, the configuration system first creates an appropriate instance of the ConfigurationSection class, and then returns the object it obtains from the GetRuntimeObject method.

By default, GetRuntimeObject simply returns the object representing the ConfigurationSection from which it is called.

Notes to Implementers You can override the GetRuntimeObject method to return a custom type at run time. For example, to restrict runtime modification of the settings in the ConfigurationSection class, you can override GetRuntimeObject and return a custom type that enforces restrictions on which settings can be modified, if any. If the runtime object is internal only, the returned object cannot be used outside the assembly that defines it. One way to create an object which derives from ConfigurationSection and can only be accessed by code in your assembly at runtime is to create an internal runtime object that has a method which returns your ConfigurationSection implementation.

The following example shows how to use the ConfigurationSection.

// Customizes the use of CustomSection
// by setting _ReadOnly to false.
// Remember you must use it along with ThrowIfReadOnly.
protected override object GetRuntimeObject()
{
    // To enable property setting just assign true to
    // the following flag.
    _ReadOnly = true;
    return base.GetRuntimeObject();



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
Show: