This documentation is archived and is not being maintained.

ImportAttribute.AllowDefault Property

Gets or sets a value that indicates whether the property, field, or parameter will be set to its type's default value when an export with the contract name is not present in the container.

Namespace:  System.ComponentModel.Composition
Assembly:  System.ComponentModel.Composition (in System.ComponentModel.Composition.dll)

member AllowDefault : bool with get, set

Property Value

Type: System.Boolean
true if the property, field, or parameter will be set to its type's default value when there is no export with the ContractName in the CompositionContainer; otherwise, false. The default is false.

The default value of the type of a property, field, or parameter is a null reference (Nothing in Visual Basic) for reference types and zero for numeric value types. For other value types, the default value will be each field of the value type initialized to zero if the field is a value type, or a null reference (Nothing in Visual Basic) if the field is a reference type.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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