DefaultSettingValueAttribute Class
Assembly: System (in system.dll)
'Declaration <AttributeUsageAttribute(AttributeTargets.Property)> _ Public NotInheritable Class DefaultSettingValueAttribute Inherits Attribute 'Usage Dim instance As DefaultSettingValueAttribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Property) */ public final class DefaultSettingValueAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Property) public final class DefaultSettingValueAttribute extends Attribute
Important: |
|---|
| DefaultSettingValueAttribute can only be applied to individual settings properties; it is invalid to apply this attribute to an entire application settings class. |
Different settings providers may have different requirements or limitations on the use of the DefaultSettingValueAttribute. For example, the LocalFileSettingsProvider does not require this attribute, and will override any value provided by this attribute if there are any values—default or user-modified— already present in the data store.
DefaultSettingValueAttribute requires that the default value can be represented as a string. As a result, settings using XML serialization cannot have a default value specified by means of this attribute. Some providers may choose to support multiple serialization schemes which can be specified at compile time using the SettingsSerializeAsAttribute.
Caution |
|---|
| The default values specified by this attribute are stored as plain text in the resultant compiled .exe or .dll file. Therefore these default values are inherently insecure. |
The following code example demonstrates the use of the DefaultSettingValueAttribute applied to three of the 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 first three of these form properties have default values associated with them.
The full code example is listed in the ApplicationSettingsBase class overview.
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.
Important: