Mono Class Library: System.Attribute Overview | Members

System.Attribute.GetCustomAttribute Method

Returns an instance of a specified custom attribute if a single instance of the attribute is in the metadata for the specified assembly.

public static Attribute GetCustomAttribute (System.Reflection.Assembly element, Type attributeType)

Parameters

element
A System.Reflection.Assembly instance.
attributeType
The Type of the custom attribute for which to check.

Returns

The single instance of Attribute of type attributeType that is applied to element. Returns null if the specified attribute was not found.

Exceptions

TypeReason
ArgumentNullExceptionelement or attributeType is null.
ArgumentExceptionattributeType is not a type derived from Attribute.
System.Reflection.AmbiguousMatchExceptionMore than one instance of the specified custom attribute was found.

Remarks

Note: If multiple instances of attributeType can be applied to element, use Attribute.GetCustomAttributes(System.Reflection.MemberInfo, Type).

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0