Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MemberInfo.GetCustomAttributes Method (Type, Boolean)

When overridden in a derived class, returns an array of custom attributes identified by Type.

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

public abstract Object[] GetCustomAttributes (
	Type attributeType,
	bool inherit
)
public abstract Object[] GetCustomAttributes (
	Type attributeType, 
	boolean inherit
)
public abstract function GetCustomAttributes (
	attributeType : Type, 
	inherit : boolean
) : Object[]
Not applicable.

Parameters

attributeType

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

inherit

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

Return Value

An array of custom attributes applied to this member, or an array with zero (0) elements if no attributes have been applied.

Exception typeCondition

TypeLoadException

A custom attribute type cannot be loaded.

ArgumentNullException

If attributeType is a null reference (Nothing in Visual Basic).

InvalidOperationException

This member belongs to a type that is loaded into the reflection-only context. See How to: Load Assemblies into the Reflection Only Context.

NoteNote:

In the .NET Framework version 2.0, this method returns security attributes on methods, constructors, and types if the attributes are stored in the new metadata format. Assemblies compiled with version 2.0 use this format. Dynamic assemblies and assemblies compiled with earlier versions of the .NET Framework use the old XML format. See Emitting Declarative Security Attributes.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft