Skip to main content
.NET Framework Class Library
ConfigurationSectionGetRuntimeObject Method

Returns a custom object when overridden in a derived class.

Namespace:   System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)
Syntax
Protected Friend Overridable Function GetRuntimeObject As [%$TOPIC/fh19sky9_en-us_VS_110_1_0_0_0_0%]
protected internal virtual [%$TOPIC/fh19sky9_en-us_VS_110_1_0_1_0_0%] GetRuntimeObject()
protected public:
virtual [%$TOPIC/fh19sky9_en-us_VS_110_1_0_2_0_0%]^ GetRuntimeObject()
abstract GetRuntimeObject : unit -> [%$TOPIC/fh19sky9_en-us_VS_110_1_0_3_0_0%]  
override GetRuntimeObject : unit -> [%$TOPIC/fh19sky9_en-us_VS_110_1_0_3_0_1%]

Return Value

Type: SystemObject
The object representing the section.
Remarks

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 that represents 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 that derives from ConfigurationSection and can only be accessed by code in your assembly at run time is to create an internal runtime object that has a method that returns your ConfigurationSection implementation.

Examples

The following example shows how to use the GetRuntimeObject method.

' Customizes the use of CustomSection 
 ' by setting _ReadOnly to false. 
' Remember you must use it along with ThrowIfReadOnly. 
Protected Overrides Function GetRuntimeObject() As Object 
   ' To enable property setting just assign true to 
   ' the following flag.
   _ReadOnly = True 
   Return MyBase.GetRuntimeObject()
End Function 'GetRuntimeObject
// 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();
        }
Version Information

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

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.