Export (0) Print
Expand All

Assembly.GetCustomAttributes Method (Boolean)

Gets all the custom attributes for this assembly.

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

abstract GetCustomAttributes : 
        inherit:bool -> Object[] 
override GetCustomAttributes : 
        inherit:bool -> Object[] 

Parameters

inherit
Type: System.Boolean

This argument is ignored for objects of type Assembly.

Return Value

Type: System.Object[]
An array that contains the custom attributes for this assembly.

Implements

_Assembly.GetCustomAttributes(Boolean)
ICustomAttributeProvider.GetCustomAttributes(Boolean)

This method implements the corresponding ICustomAttributeProvider interface method. Therefore, the inherit parameter must be specified even though it is ignored.

NoteNote

In the .NET Framework version 2.0, this method returns security attributes if they 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.

A pseudo-attribute indicates bits of the core metadata that must be set when the attribute is present. Unlike a custom attribute that extends the metadata for a type and is saved along with the type, a pseudo-attribute modifies the metadata for the type and then is discarded. Some of the resulting bits cannot be accessed using existing reflection APIs.

The following table summarizes the different pseudo-attributes and the accessors for the bits that are available in reflection.

Pseudo-Attribute

Metadata Bits

Reflection Accessor

DllImportAttribute

CorPInvokeMap

DLL name

No accessor for PInvokeMap for ordinary method/global method attributes.

No accessor for DLL name.

GuidAttribute

Stored as a real custom attribute.

Accessed as a real custom attribute.

ComImportAttribute

CorTypeAttr.tdImport

Type.Attributes.Import

SerializableAttribute

CorTypeAttr.tdSerializable

Type.Attributes.Serializable

NonSerializedAttribute

CorFieldAttr.fdNotSerialized

FieldInfo.Attributes.NotSerialized

MethodImplAttribute

CorMethodImpl

MethodInfo.GetMethodImplementationFlags()

ConstructorInfo.GetMethodImplementationFlags()

MarshalAsAttribute

Various bits.

No accessor.

PreserveSigAttribute

CorMethodImpl.miOLE

MethodInfo.GetMethodImplementationFlags().OLE

ConstructorInfo.GetMethodImplementationFlags().OLE

InAttribute

CorParamAttr.pdIn

ParameterInfo.Attributes.In

OutAttribute

CorParamAttr.pdOut

ParameterInfo.Attributes.Out

StructLayoutAttribute

CorTypeAttr.tdLayoutSequential

CorTypeAttr.tdExplicitLayout

CorTypeAttr.tdAnsiClass

CorTypeAttr.tdUnicodeClass

CorTypeAttr.tdAutoClass

Class packing.

Type.Attributes.LayoutSequential

Type.Attributes.ExplicitLayout

Type.Attributes.AnsiClass

Type.Attributes.UnicodeClass

Type.Attributes.AutoClass

No accessor.

FieldOffsetAttribute

Field offset.

No accessor.

AssemblyLoadAttribute

CorAssemblyFlags

No accessor or enumerator.

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft