TypeBuilder.SetCustomAttribute Method
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.
Sets a custom attribute.
SetCustomAttribute(CustomAttributeBuilder) |
Set a custom attribute using a custom attribute builder. |
SetCustomAttribute(ConstructorInfo, Byte[]) |
Sets a custom attribute using a specified custom attribute blob. |
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
Set a custom attribute using a custom attribute builder.
public:
void SetCustomAttribute(System::Reflection::Emit::CustomAttributeBuilder ^ customBuilder);
public void SetCustomAttribute(System.Reflection.Emit.CustomAttributeBuilder customBuilder);
member this.SetCustomAttribute : System.Reflection.Emit.CustomAttributeBuilder -> unit
Public Sub SetCustomAttribute (customBuilder As CustomAttributeBuilder)
Parameters
- customBuilder
- CustomAttributeBuilder
An instance of a helper class to define the custom attribute.
Exceptions
customBuilder
is null
.
For the current dynamic type, the IsGenericType property is true
, but the IsGenericTypeDefinition property is false
.
Remarks
Märkus
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 ja muud versioonid
Toode | Versioonid |
---|---|
.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 |
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
Sets a custom attribute using a specified custom attribute blob.
public:
void SetCustomAttribute(System::Reflection::ConstructorInfo ^ con, cli::array <System::Byte> ^ binaryAttribute);
public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
[System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(System.Reflection.ConstructorInfo con, byte[] binaryAttribute);
member this.SetCustomAttribute : System.Reflection.ConstructorInfo * byte[] -> unit
[<System.Runtime.InteropServices.ComVisible(true)>]
member this.SetCustomAttribute : System.Reflection.ConstructorInfo * byte[] -> unit
Public Sub SetCustomAttribute (con As ConstructorInfo, binaryAttribute As Byte())
Parameters
- con
- ConstructorInfo
The constructor for the custom attribute.
- binaryAttribute
- Byte[]
A byte blob representing the attributes.
- Attributes
Exceptions
con
or binaryAttribute
is null
.
For the current dynamic type, the IsGenericType property is true
, but the IsGenericTypeDefinition property is false
.
Remarks
For more information on how to format binaryAttribute
, see ECMA C# and Common Language Infrastructure Standards and Standard ECMA-335 - Common Language Infrastructure (CLI).
Märkus
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 ja muud versioonid
Toode | Versioonid |
---|---|
.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 |
Toote „.NET“ tagasiside
.NET on avatud lähtekoodiga projekt. Tagasiside andmiseks valige link: