System.Configuration Namesp ...


.NET Framework Class Library
SettingsProvider Class

Acts as a base class for deriving custom settings providers in the application settings architecture.

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

Visual Basic (Declaration)
Public MustInherit Class SettingsProvider _
    Inherits ProviderBase
Visual Basic (Usage)
Dim instance As SettingsProvider
C#
public abstract class SettingsProvider : ProviderBase
Visual C++
public ref class SettingsProvider abstract : public ProviderBase
JScript
public abstract class SettingsProvider extends ProviderBase
Remarks

A settings provider defines the mechanism for storing configuration data used in the application settings architecture. The .NET Framework contains a single default settings provider, LocalFileSettingsProvider, which stores configuration data to the local file system. However, you can create alternate storage mechanisms by deriving from the abstract SettingsProvider class. The provider that a wrapper class uses is determined by decorating the wrapper class with the SettingsProviderAttribute. If this attribute is not provided, the default, LocalFileSettingsProvider, is used.

When you create a custom settings provider, at minimum, you must provide implementations for the three methods of this class: GetPropertyValues, SetPropertyValues and ApplicationName.

For client applications, you can add more standardized functionality to a custom provider by also implementing the IApplicationSettingsProvider interface. This interface mirrors methods found in the ApplicationSettingsBase class, which mainly enables versioning support.

Typically, you should design settings providers to be single-instanced to avoid storage resource contention. Providers should also be thread-safe because they can be called simultaneously from multiple wrapper instances in a single application domain or from multiple applications in different domains.

At minimum, a settings provider must recognize three attributes—ApplicationScopedSettingAttribute, UserScopedSettingAttribute, and DefaultSettingValueAttribute. For a full listing of attributes that can be applied to application settings, see Application Settings Attributes. A custom setting provider should resolve attributes applied to settings properties in the following manner:

  1. If the provider can fulfill the request implied by the attribute, obviously it should do so.

  2. If the provider cannot fulfill the request, it should ignore it silently.

  3. If two or more properties conflict; for example, a property being decorated with both ApplicationScopedSettingAttribute and UserScopedSettingAttribute; the provider should throw a ConfigurationException.

Inheritance Hierarchy

System..::.Object
  System.Configuration.Provider..::.ProviderBase
    System.Configuration..::.SettingsProvider
      System.Configuration..::.LocalFileSettingsProvider
      System.Web.ClientServices.Providers..::.ClientSettingsProvider
      System.Web.Profile..::.ProfileProvider
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

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

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0
See Also

Reference

Other Resources

Tags :


Page view tracker