TypeBuilder.GetCustomAttributes Method (Type, Boolean)

Returns all the custom attributes of the current type that are assignable to a specified type.

Namespace:  System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

public override Object[] GetCustomAttributes(
	Type attributeType,
	bool inherit
)

Parameters

attributeType
Type: System.Type

The type of attribute to search for. Only attributes that are assignable to this type are returned.

inherit
Type: System.Boolean

Specifies whether to search this member's inheritance chain to find the attributes.

Return Value

Type: System.Object[]
An array of custom attributes defined on the current type.

Implements

ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)
_MemberInfo.GetCustomAttributes(Type, Boolean)

ExceptionCondition
NotSupportedException

This method is not currently supported for incomplete types. Retrieve the type using GetType and call GetCustomAttributes on the returned Type.

ArgumentNullException

attributeType is null.

ArgumentException

The type must be a type provided by the underlying runtime system.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft