SettingsSavedEventArgs.FailedSettingsList Property

Definition

Gets the settings that the ClientSettingsProvider was unable to save to the server.

C#
public System.Collections.ObjectModel.ReadOnlyCollection<string> FailedSettingsList { get; }

Property Value

The settings that were not saved.

Examples

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

C#
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);
    }
}

Remarks

One reason that the provider might fail to save the settings is if the current user has been logged out. You can use the FailedSettingsList property to determine whether any settings were not successfully saved.

Applies to

Product Versions
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also