ModuleBuilder.SetCustomAttribute Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Applies a custom attribute to this module.

Overloads

SetCustomAttribute(CustomAttributeBuilder)

Applies a custom attribute to this module by using a custom attribute builder.

SetCustomAttribute(ConstructorInfo, Byte[])

Applies a custom attribute to this module by using a specified binary large object (BLOB) that represents the attribute.

SetCustomAttribute(CustomAttributeBuilder)

Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs

Applies a custom attribute to this module by using a custom attribute builder.

C#
public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);

Parameters

customBuilder
CustomAttributeBuilder

An instance of a helper class that specifies the custom attribute to apply.

Exceptions

customBuilder is null.

Remarks

Note

Starting with the .NET Framework 2.0 Service Pack 1, this member no longer requires ReflectionPermission with the ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the .NET Framework 3.5 or later.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided), 2.1

SetCustomAttribute(ConstructorInfo, Byte[])

Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs

Applies a custom attribute to this module by using a specified binary large object (BLOB) that represents the attribute.

C#
public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
C#
[System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);

Parameters

con
ConstructorInfo

The constructor for the custom attribute.

binaryAttribute
Byte[]

A byte BLOB representing the attribute.

Attributes

Exceptions

con or binaryAttribute is null.

Remarks

For more information about how to format binaryAttribute, see the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics". For more information, see ECMA 335 Common Language Infrastructure (CLI).

Note

Starting with the .NET Framework 2.0 Service Pack 1, this member no longer requires ReflectionPermission with the ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the .NET Framework 3.5 or later.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided), 2.1