Export (0) Print
Expand All

ClientSettingsProvider Class

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

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

'Declaration
<PermissionSetAttribute(SecurityAction.LinkDemand, Name := "FullTrust")> _
<PermissionSetAttribute(SecurityAction.InheritanceDemand, Name := "FullTrust")> _
Public Class ClientSettingsProvider _
	Inherits SettingsProvider _
	Implements IApplicationSettingsProvider
'Usage
Dim instance As ClientSettingsProvider

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 link demand and an inheritance demand at the class level that applies to all members. A SecurityException is thrown when the immediate caller or 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 WithEvents settingsProvider As ClientSettingsProvider = My.Settings _
    .Providers("System.Web.ClientServices.Providers.ClientSettingsProvider")

Private Sub Form1_SettingsSaved(ByVal sender As Object, _
    ByVal e As SettingsSavedEventArgs) _
    Handles settingsProvider.SettingsSaved

    ' If any settings were not saved, display a list of them. 
    If e.FailedSettingsList.Count > 0 Then 

        Dim failedSettings As String = String.Join( _
            Environment.NewLine, e.FailedSettingsList.ToArray())

        Dim message As String = 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)

    End If 

End Sub

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

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

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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.

.NET Framework

Supported in: 3.5

Community Additions

ADD
Show:
© 2014 Microsoft