Editar

Compartilhar via


SettingsPropertyValue.PropertyValue Property

Definition

Gets or sets the value of the SettingsProperty object.

public:
 property System::Object ^ PropertyValue { System::Object ^ get(); void set(System::Object ^ value); };
public object PropertyValue { get; set; }
member this.PropertyValue : obj with get, set
Public Property PropertyValue As Object

Property Value

The value of the SettingsProperty object. When this value is set, the IsDirty property is set to true and UsingDefaultValue is set to false.

When a value is first accessed from the PropertyValue property, and if the value was initially stored into the SettingsPropertyValue object as a serialized representation using the SerializedValue property, the PropertyValue property will trigger deserialization of the underlying value. As a side effect, the Deserialized property will be set to true.

If this chain of events occurs in ASP.NET, and if an error occurs during the deserialization process, the error is logged using the health-monitoring feature of ASP.NET. By default, this means that deserialization errors will show up in the Application Event Log when running under ASP.NET. If this process occurs outside of ASP.NET, and if an error occurs during deserialization, the error is suppressed, and the remainder of the logic during deserialization occurs. If there is no serialized value to deserialize when the deserialization is attempted, then SettingsPropertyValue object will instead attempt to return a default value if one was configured as defined on the associated SettingsProperty instance. In this case, if the DefaultValue property was set to either null, or to the string "[null]", then the SettingsPropertyValue object will initialize the PropertyValue property to either null for reference types, or to the default value for the associated value type. On the other hand, if DefaultValue property holds a valid object reference or string value (other than "[null]"), then the DefaultValue property is returned instead.

If there is no serialized value to deserialize when the deserialization is attempted, and no default value was specified, then an empty string will be returned for string types. For all other types, a default instance will be returned by calling CreateInstance(Type) - for reference types this means an attempt will be made to create an object instance using the parameterless constructor. If this attempt fails, then null is returned.

Exceptions

While attempting to use the default value from the DefaultValue property, an error occurred. Either the attempt to convert DefaultValue property to a valid type failed, or the resulting value was not compatible with the type defined by PropertyType.

Applies to