CustomAttributeBuilder 建構函式

定義

初始化 CustomAttributeBuilder 類別的執行個體。Initializes an instances of the CustomAttributeBuilder class.

多載

CustomAttributeBuilder(ConstructorInfo, Object[])

指定自訂屬性的建構函式與建構函式的引數,初始化 CustomAttributeBuilder 類別的執行個體。Initializes an instance of the CustomAttributeBuilder class given the constructor for the custom attribute and the arguments to the constructor.

CustomAttributeBuilder(ConstructorInfo, Object[], FieldInfo[], Object[])

初始化 CustomAttributeBuilder 類別的執行個體,該類別指定了自訂屬性的建構函式、建構函式的引數,以及一組命名的欄位/值配對。Initializes an instance of the CustomAttributeBuilder class given the constructor for the custom attribute, the arguments to the constructor, and a set of named field/value pairs.

CustomAttributeBuilder(ConstructorInfo, Object[], PropertyInfo[], Object[])

初始化 CustomAttributeBuilder 類別的執行個體,該類別指定了自訂屬性的建構函式、建構函式的引數,以及一組命名的屬性或值配對。Initializes an instance of the CustomAttributeBuilder class given the constructor for the custom attribute, the arguments to the constructor, and a set of named property or value pairs.

CustomAttributeBuilder(ConstructorInfo, Object[], PropertyInfo[], Object[], FieldInfo[], Object[])

初始化 CustomAttributeBuilder 類別的執行個體,該類別指定了自訂屬性的建構函式、建構函式的引數、一組命名的屬性或值配對,以及一組命名的欄位或值配對。Initializes an instance of the CustomAttributeBuilder class given the constructor for the custom attribute, the arguments to the constructor, a set of named property or value pairs, and a set of named field or value pairs.

CustomAttributeBuilder(ConstructorInfo, Object[])

指定自訂屬性的建構函式與建構函式的引數,初始化 CustomAttributeBuilder 類別的執行個體。Initializes an instance of the CustomAttributeBuilder class given the constructor for the custom attribute and the arguments to the constructor.

public:
 CustomAttributeBuilder(System::Reflection::ConstructorInfo ^ con, cli::array <System::Object ^> ^ constructorArgs);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object[] constructorArgs);
new System.Reflection.Emit.CustomAttributeBuilder : System.Reflection.ConstructorInfo * obj[] -> System.Reflection.Emit.CustomAttributeBuilder
Public Sub New (con As ConstructorInfo, constructorArgs As Object())

參數

con
ConstructorInfo

自訂屬性的建構函式。The constructor for the custom attribute.

constructorArgs
Object[]

自訂屬性之建構函式的引數。The arguments to the constructor of the custom attribute.

例外狀況

con 為靜態或私用的。con is static or private.

-或--or- 提供的引數數目不符合建構函式呼叫慣例所需之建構函式的參數數目。The number of supplied arguments does not match the number of parameters of the constructor as required by the calling convention of the constructor.

-或--or- 提供的引數類型不符合建構函式中宣告的參數類型。The type of supplied argument does not match the type of the parameter declared in the constructor.

-或--or- 提供的引數不是 StringType 的參考類型。A supplied argument is a reference type other than String or Type.

conconstructorArgsnullcon or constructorArgs is null.

備註

陣列的元素 constructorArgs 會限制為元素類型。The elements of the constructorArgs array are restricted to element types. 它們可以是、、、、、、、、、 byte sbyte int uint long ulong float double String charbool 、列舉、型別、轉換成物件的任何先前類型,或是任何先前型別的以零為基底的單一維度陣列。They can be byte, sbyte, int, uint, long, ulong, float, double, String, char, bool, an enum, a type, any of the previous types that was cast to an object, or a single-dimension, zero-based array of any of the previous types.

適用於

CustomAttributeBuilder(ConstructorInfo, Object[], FieldInfo[], Object[])

初始化 CustomAttributeBuilder 類別的執行個體,該類別指定了自訂屬性的建構函式、建構函式的引數,以及一組命名的欄位/值配對。Initializes an instance of the CustomAttributeBuilder class given the constructor for the custom attribute, the arguments to the constructor, and a set of named field/value pairs.

public:
 CustomAttributeBuilder(System::Reflection::ConstructorInfo ^ con, cli::array <System::Object ^> ^ constructorArgs, cli::array <System::Reflection::FieldInfo ^> ^ namedFields, cli::array <System::Object ^> ^ fieldValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object[] fieldValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object[] fieldValues);
new System.Reflection.Emit.CustomAttributeBuilder : System.Reflection.ConstructorInfo * obj[] * System.Reflection.FieldInfo[] * obj[] -> System.Reflection.Emit.CustomAttributeBuilder
Public Sub New (con As ConstructorInfo, constructorArgs As Object(), namedFields As FieldInfo(), fieldValues As Object())

參數

con
ConstructorInfo

自訂屬性的建構函式。The constructor for the custom attribute.

constructorArgs
Object[]

自訂屬性之建構函式的引數。The arguments to the constructor of the custom attribute.

namedFields
FieldInfo[]

自訂屬性的具名欄位。Named fields of the custom attribute.

fieldValues
Object[]

自訂屬性的具名欄位值。Values for the named fields of the custom attribute.

例外狀況

namedFieldsfieldValues 陣列的長度不同。The lengths of the namedFields and fieldValues arrays are different.

-或--or- con 為靜態或私用的。con is static or private.

-或--or- 提供的引數數目不符合建構函式呼叫慣例所需之建構函式的參數數目。The number of supplied arguments does not match the number of parameters of the constructor as required by the calling convention of the constructor.

-或--or- 提供的引數類型不符合建構函式中宣告的參數類型。The type of supplied argument does not match the type of the parameter declared in the constructor.

-或--or- 欄位值型別不符合具名欄位型別。The types of the field values do not match the types of the named fields.

-或--or- 欄位不屬於做為建構函式的相同類別或基底類別。The field does not belong to the same class or base class as the constructor.

-或--or- 提供的引數或具名欄位是 StringType 以外的參考型別。A supplied argument or named field is a reference type other than String or Type.

其中一個參數為 nullOne of the parameters is null.

備註

和陣列的元素 constructorArgs fieldValues 會限制為元素類型。The elements of the constructorArgs and fieldValues arrays are restricted to element types. 它們可以是、、、、、、、、、 byte sbyte int uint long ulong float double String charbool 、列舉、型別、轉換成物件的任何先前類型,或是任何先前型別的以零為基底的單一維度陣列。They can be byte, sbyte, int, uint, long, ulong, float, double, String, char, bool, an enum, a type, any of the previous types that was cast to an object, or a single-dimension, zero-based array of any of the previous types.

重要

請勿在中包含私用欄位 namedFieldsDo not include private fields in namedFields. CustomAttributeFormatExceptionGetCustomAttributes 稍後在完成的型別上呼叫方法時,就會擲回這個例外狀況。Doing so will cause CustomAttributeFormatException to be thrown when the GetCustomAttributes method is later called on the completed type.

適用於

CustomAttributeBuilder(ConstructorInfo, Object[], PropertyInfo[], Object[])

初始化 CustomAttributeBuilder 類別的執行個體,該類別指定了自訂屬性的建構函式、建構函式的引數,以及一組命名的屬性或值配對。Initializes an instance of the CustomAttributeBuilder class given the constructor for the custom attribute, the arguments to the constructor, and a set of named property or value pairs.

public:
 CustomAttributeBuilder(System::Reflection::ConstructorInfo ^ con, cli::array <System::Object ^> ^ constructorArgs, cli::array <System::Reflection::PropertyInfo ^> ^ namedProperties, cli::array <System::Object ^> ^ propertyValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues);
new System.Reflection.Emit.CustomAttributeBuilder : System.Reflection.ConstructorInfo * obj[] * System.Reflection.PropertyInfo[] * obj[] -> System.Reflection.Emit.CustomAttributeBuilder
Public Sub New (con As ConstructorInfo, constructorArgs As Object(), namedProperties As PropertyInfo(), propertyValues As Object())

參數

con
ConstructorInfo

自訂屬性的建構函式。The constructor for the custom attribute.

constructorArgs
Object[]

自訂屬性之建構函式的引數。The arguments to the constructor of the custom attribute.

namedProperties
PropertyInfo[]

自訂屬性 (Attribute) 的具名屬性 (Property)。Named properties of the custom attribute.

propertyValues
Object[]

自訂屬性 (Attribute) 的具名屬性 (Property) 值。Values for the named properties of the custom attribute.

例外狀況

namedPropertiespropertyValues 陣列的長度不同。The lengths of the namedProperties and propertyValues arrays are different.

-或--or- con 為靜態或私用的。con is static or private.

-或--or- 提供的引數數目不符合建構函式呼叫慣例所需之建構函式的參數數目。The number of supplied arguments does not match the number of parameters of the constructor as required by the calling convention of the constructor.

-或--or- 提供的引數類型不符合建構函式中宣告的參數類型。The type of supplied argument does not match the type of the parameter declared in the constructor.

-或--or- 屬性值型別不符合具名屬性型別。The types of the property values do not match the types of the named properties.

-或--or- 屬性不具有 Setter 方法。A property has no setter method.

-或--or- 屬性不屬於做為建構函式的相同類別或基底類別。The property does not belong to the same class or base class as the constructor.

-或--or- 提供的引數或具名屬性是 StringType 以外的參考型別。A supplied argument or named property is a reference type other than String or Type.

其中一個參數為 nullOne of the parameters is null.

備註

和陣列的元素 constructorArgs propertyValues 會限制為元素類型。The elements of the constructorArgs and propertyValues arrays are restricted to element types. 它們可以是、、、、、、、、、 byte sbyte int uint long ulong float double String charbool 、列舉、型別、轉換成物件的任何先前類型,或是任何先前型別的以零為基底的單一維度陣列。They can be byte, sbyte, int, uint, long, ulong, float, double, String, char, bool, an enum, a type, any of the previous types that was cast to an object, or a single-dimension, zero-based array of any of the previous types.

重要

請勿在中包含私用屬性 namedPropertiesDo not include private properties in namedProperties. CustomAttributeFormatExceptionGetCustomAttributes 稍後在完成的型別上呼叫方法時,就會擲回這個例外狀況。Doing so will cause CustomAttributeFormatException to be thrown when the GetCustomAttributes method is later called on the completed type.

適用於

CustomAttributeBuilder(ConstructorInfo, Object[], PropertyInfo[], Object[], FieldInfo[], Object[])

初始化 CustomAttributeBuilder 類別的執行個體,該類別指定了自訂屬性的建構函式、建構函式的引數、一組命名的屬性或值配對,以及一組命名的欄位或值配對。Initializes an instance of the CustomAttributeBuilder class given the constructor for the custom attribute, the arguments to the constructor, a set of named property or value pairs, and a set of named field or value pairs.

public:
 CustomAttributeBuilder(System::Reflection::ConstructorInfo ^ con, cli::array <System::Object ^> ^ constructorArgs, cli::array <System::Reflection::PropertyInfo ^> ^ namedProperties, cli::array <System::Object ^> ^ propertyValues, cli::array <System::Reflection::FieldInfo ^> ^ namedFields, cli::array <System::Object ^> ^ fieldValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues, System.Reflection.FieldInfo[] namedFields, object[] fieldValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues, System.Reflection.FieldInfo[] namedFields, object[] fieldValues);
new System.Reflection.Emit.CustomAttributeBuilder : System.Reflection.ConstructorInfo * obj[] * System.Reflection.PropertyInfo[] * obj[] * System.Reflection.FieldInfo[] * obj[] -> System.Reflection.Emit.CustomAttributeBuilder
Public Sub New (con As ConstructorInfo, constructorArgs As Object(), namedProperties As PropertyInfo(), propertyValues As Object(), namedFields As FieldInfo(), fieldValues As Object())

參數

con
ConstructorInfo

自訂屬性的建構函式。The constructor for the custom attribute.

constructorArgs
Object[]

自訂屬性之建構函式的引數。The arguments to the constructor of the custom attribute.

namedProperties
PropertyInfo[]

自訂屬性 (Attribute) 的具名屬性 (Property)。Named properties of the custom attribute.

propertyValues
Object[]

自訂屬性 (Attribute) 的具名屬性 (Property) 值。Values for the named properties of the custom attribute.

namedFields
FieldInfo[]

自訂屬性的具名欄位。Named fields of the custom attribute.

fieldValues
Object[]

自訂屬性的具名欄位值。Values for the named fields of the custom attribute.

例外狀況

namedPropertiespropertyValues 陣列的長度不同。The lengths of the namedProperties and propertyValues arrays are different.

-或--or- namedFieldsfieldValues 陣列的長度不同。The lengths of the namedFields and fieldValues arrays are different.

-或--or- con 為靜態或私用的。con is static or private.

-或--or- 提供的引數數目不符合建構函式呼叫慣例所需之建構函式的參數數目。The number of supplied arguments does not match the number of parameters of the constructor as required by the calling convention of the constructor.

-或--or- 提供的引數類型不符合建構函式中宣告的參數類型。The type of supplied argument does not match the type of the parameter declared in the constructor.

-或--or- 屬性值型別不符合具名屬性型別。The types of the property values do not match the types of the named properties.

-或--or- 欄位值型別不符合對應欄位型別的型別。The types of the field values do not match the types of the corresponding field types.

-或--or- 屬性不具有 Setter。A property has no setter.

-或--or- 屬性或欄位不屬於做為建構函式的相同類別或基底類別。The property or field does not belong to the same class or base class as the constructor.

-或--or- 提供的引數、具名屬性或具名欄位是 StringType 以外的參考型別。A supplied argument, named property, or named field is a reference type other than String or Type.

其中一個參數為 nullOne of the parameters is null.

備註

constructorArgs、或陣列的元素 propertyValues fieldValues 會限制為元素類型。The elements of the constructorArgs, propertyValues, or fieldValues arrays are restricted to element types. 它們可以是、、、、、、、、、 byte sbyte int uint long ulong float double String charbool 、列舉、型別、轉換成物件的任何先前類型,或是任何先前型別的以零為基底的單一維度陣列。They can be byte, sbyte, int, uint, long, ulong, float, double, String, char, bool, an enum, a type, any of the previous types that was cast to an object, or a single-dimension, zero-based array of any of the previous types.

重要

請勿在或中包含私用屬性或欄位 namedProperties namedFieldsDo not include private properties or fields in namedProperties or namedFields. CustomAttributeFormatExceptionGetCustomAttributes 稍後在完成的型別上呼叫方法時,就會擲回這個例外狀況。Doing so will cause CustomAttributeFormatException to be thrown when the GetCustomAttributes method is later called on the completed type.

適用於