Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

UserScopedSettingAttribute Class

Note: This class is new in the .NET Framework version 2.0.

Specifies that an application settings group or property contains distinct values for each user of an application. This class cannot be inherited.

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

[AttributeUsageAttribute(AttributeTargets.Property)] 
public sealed class UserScopedSettingAttribute : SettingAttribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Property) */ 
public final class UserScopedSettingAttribute extends SettingAttribute
AttributeUsageAttribute(AttributeTargets.Property) 
public final class UserScopedSettingAttribute extends SettingAttribute

Application settings properties have a scope that is based either at the application or the user level. As the categories imply, application-scoped properties present uniform values to all users of the application, whereas user-scoped properties have dedicated values for each user of the application.

The UserScopedSettingAttribute indicates that a property should be considered a user level setting, and that appropriate storage decisions should be made accordingly by the settings provider.

A scope attribute is required for each application settings property. If a property is not applied with either a ApplicationScopedSettingAttribute or UserScopedSettingAttribute, the property is ignored by the settings provider—it is not serialized. It is invalid, however, to apply both attributes to the same settings property. Such an attempt will cause a ConfigurationErrorsException to be thrown.

The following code example demonstrates the use of the UserScopedSettingAttribute applied to all four properties of the FormSettings wrapper class, which is derived from the ApplicationSettingsBase class. This class is used to persist the location, size, background color, and text of form. The full code example is listed in the ApplicationSettingsBase class overview.

//Application settings wrapper class
sealed class FormSettings : ApplicationSettingsBase
{
    [UserScopedSettingAttribute()]
    public String FormText
    {
        get { return (String)this["FormText"]; 
        set { this["FormText"] = value; 
    

    [UserScopedSetting()]
    [DefaultSettingValueAttribute("0, 0")]
    public Point FormLocation
    {
        get { return (Point)(this["FormLocation"]); 
        set { this["FormLocation"] = value; 
    

    [UserScopedSetting()]
    [DefaultSettingValueAttribute("225, 200")]
    public Size FormSize
    {
        get { return (Size)this["FormSize"]; 
        set { this["FormSize"] = value; 
    

    [UserScopedSetting()]
    [DefaultSettingValueAttribute("LightGray")]
    public Color FormBackColor
    {
        get { return (Color)this["FormBackColor"]; 
        set { this["FormBackColor"] = value; 
    



System.Object
   System.Attribute
     System.Configuration.SettingAttribute
      System.Configuration.UserScopedSettingAttribute
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 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.