ClientSettingsProvider Class

Enables Windows-based applications to retrieve user settings from a Web settings service.

System.Object
  System.Configuration.Provider.ProviderBase
    System.Configuration.SettingsProvider
      System.Web.ClientServices.Providers.ClientSettingsProvider

Namespace:  System.Web.ClientServices.Providers
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
public class ClientSettingsProvider : SettingsProvider, 
	IApplicationSettingsProvider

The ClientSettingsProvider type exposes the following members.

  NameDescription
Public methodClientSettingsProviderInitializes a new instance of the ClientSettingsProvider class.
Top

  NameDescription
Public propertyApplicationNameThis property is not used by this class. (Overrides SettingsProvider.ApplicationName.)
Public propertyDescriptionGets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs). (Inherited from ProviderBase.)
Public propertyNameGets the friendly name used to refer to the provider during configuration. (Inherited from ProviderBase.)
Public propertyStatic memberServiceUriGets or sets the Web settings service location.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetPreviousVersionGets the previous version of the specified property.
Public methodStatic memberGetPropertyMetadataGets a collection of metadata for all properties retrieved from the specified Web settings service.
Public methodGetPropertyValuesReturns the collection of settings property values for the specified application instance and settings property group. (Overrides SettingsProvider.GetPropertyValues(SettingsContext, SettingsPropertyCollection).)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeInitializes the provider. (Overrides ProviderBase.Initialize(String, NameValueCollection).)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodResetResets all user settings to their default values.
Public methodSetPropertyValuesSets the values of the specified group of property settings. (Overrides SettingsProvider.SetPropertyValues(SettingsContext, SettingsPropertyValueCollection).)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodUpgradeThis method is not used by this class.
Top

  NameDescription
Public eventSettingsSavedOccurs after the settings provider attempts to save the property values to the Web settings service.
Top

You can use client application services to retrieve user settings from an existing Web settings service by configuring your application to use the ClientSettingsProvider class. For more information, see How to: Configure Client Application Services. After configuration, you can get and set user settings through an application settings class derived from ApplicationSettingsBase and configured to use the ClientSettingsProvider class. You can use Visual Studio to generate a Settings class for your project (accessed as Properties.Settings.Default in C# and My.Settings in Visual Basic). For more information about application settings, see Application Settings Overview.

You can retrieve the current ClientSettingsProvider through the ApplicationSettingsBase.Providers property using the fully-qualified ClientSettingsProvider class name as a key. You can also retrieve the provider through the SettingsLoadedEventArgs.Provider property when you handle the ApplicationSettingsBase.SettingsLoaded event.

NoteNote

This class contains a SecurityCriticalAttribute at the class level that applies to all members of the class. A run-time exception is thrown if the immediate caller is security-transparent or partially trusted. For more information about security-critical types and members, see Security-Transparent Code, Level 2.

NoteNote

This class contains an inheritance demand at the class level that applies to all members. A SecurityException is thrown when the derived class does not have full-trust permission. For details about security demands, see Link Demands and Inheritance Demands.

The following example code demonstrates how to use this event to display a list of settings that were not successfully saved.


private void AttachSettingsSavedEventHandler()
{
    ((ClientSettingsProvider)Properties.Settings.Default.Providers
        ["System.Web.ClientServices.Providers.ClientSettingsProvider"])
        .SettingsSaved +=
        new EventHandler<SettingsSavedEventArgs>(Form1_SettingsSaved);
}

private void Form1_SettingsSaved(object sender,
    SettingsSavedEventArgs e)
{
    // If any settings were not saved, display a list of them.
    if (e.FailedSettingsList.Count > 0)
    {
        String failedSettings = String.Join(
            Environment.NewLine,
            e.FailedSettingsList.ToArray());

        String message = String.Format("{0}{1}{1}{2}",
            "The following setting(s) were not saved:",
            Environment.NewLine, failedSettings);

        MessageBox.Show(message, "Unable to save settings",
            MessageBoxButtons.OK, MessageBoxIcon.Warning);
    }
}


.NET Framework

Supported in: 4, 3.5

  • InheritanceDemand 

    for full trust for inheritors. This class cannot be inherited by partially trusted code.

  • SecurityCriticalAttribute 

    requires full trust for the immediate caller. This class cannot be used by partially trusted or transparent code.

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft