TypeBuilder.SetCustomAttribute 方法    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
设置自定义属性。
重载
| SetCustomAttribute(CustomAttributeBuilder) | 
						 使用自定义属性生成器设置自定义属性。  | 
        	
| SetCustomAttribute(ConstructorInfo, Byte[]) | 
						 使用指定的自定义属性 blob 设置自定义属性。  | 
        	
SetCustomAttribute(CustomAttributeBuilder)
- Source:
 - TypeBuilder.cs
 
- Source:
 - TypeBuilder.cs
 
- Source:
 - TypeBuilder.cs
 
- Source:
 - TypeBuilder.cs
 
使用自定义属性生成器设置自定义属性。
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)
	参数
- customBuilder
 - CustomAttributeBuilder
 
用于定义自定义属性的帮助程序类的一个实例。
例外
              customBuilder 为 null。
对于当前的动态类型,属性 IsGenericType 的值为 true,但属性 IsGenericTypeDefinition 的值为 false。
注解
注意
从 .NET Framework 2.0 Service Pack 1 开始,此成员不再需要ReflectionPermission标志ReflectionPermissionFlag.ReflectionEmit。 (请参阅反射发出中的安全问题.) 若要使用此功能,应用程序应面向.NET Framework 3.5 或更高版本。
适用于
SetCustomAttribute(ConstructorInfo, Byte[])
- Source:
 - TypeBuilder.cs
 
- Source:
 - TypeBuilder.cs
 
- Source:
 - TypeBuilder.cs
 
- Source:
 - TypeBuilder.cs
 
使用指定的自定义属性 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())
	参数
- con
 - ConstructorInfo
 
自定义属性的构造函数。
- binaryAttribute
 - Byte[]
 
表示属性的字节 blob。
- 属性
 
例外
              con 或 binaryAttribute 为 null。
对于当前的动态类型,属性 IsGenericType 的值为 true,但属性 IsGenericTypeDefinition 的值为 false。
注解
有关如何设置 格式 binaryAttribute的详细信息,请参阅 ECMA C# 和公共语言基础结构标准 以及 标准 ECMA-335 - 公共语言基础结构 (CLI) 。
注意
从 .NET Framework 2.0 Service Pack 1 开始,此成员不再需要ReflectionPermission标志ReflectionPermissionFlag.ReflectionEmit。 (请参阅反射发出中的安全问题.) 若要使用此功能,应用程序应面向.NET Framework 3.5 或更高版本。