CustomAttributeBuilder Constructors
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.
Initializes an instances of the CustomAttributeBuilder
class.
Overloads
CustomAttributeBuilder(ConstructorInfo, Object[]) |
Initializes an instance of the |
CustomAttributeBuilder(ConstructorInfo, Object[], FieldInfo[], Object[]) |
Initializes an instance of the |
CustomAttributeBuilder(ConstructorInfo, Object[], PropertyInfo[], Object[]) |
Initializes an instance of the |
CustomAttributeBuilder(ConstructorInfo, Object[], PropertyInfo[], Object[], FieldInfo[], Object[]) |
Initializes an instance of the |
CustomAttributeBuilder(ConstructorInfo, Object[])
- Source:
- CustomAttributeBuilder.cs
- Source:
- CustomAttributeBuilder.cs
- Source:
- CustomAttributeBuilder.cs
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())
Parameters
- con
- ConstructorInfo
The constructor for the custom attribute.
- constructorArgs
- Object[]
The arguments to the constructor of the custom attribute.
Exceptions
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-
A supplied argument is a reference type other than String or Type.
con
or constructorArgs
is null
.
Remarks
The elements of the constructorArgs
array are restricted to element types. 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.
Applies to
CustomAttributeBuilder(ConstructorInfo, Object[], FieldInfo[], Object[])
- Source:
- CustomAttributeBuilder.cs
- Source:
- CustomAttributeBuilder.cs
- Source:
- CustomAttributeBuilder.cs
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())
Parameters
- 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.
Exceptions
The lengths of the namedFields
and fieldValues
arrays are different.
-or-
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-
A supplied argument or named field is a reference type other than String or Type.
One of the parameters is null
.
Remarks
The elements of the constructorArgs
and fieldValues
arrays are restricted to element types. 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.
Important
Do not include private fields in namedFields
. Doing so will cause CustomAttributeFormatException to be thrown when the GetCustomAttributes method is later called on the completed type.
Applies to
CustomAttributeBuilder(ConstructorInfo, Object[], PropertyInfo[], Object[])
- Source:
- CustomAttributeBuilder.cs
- Source:
- CustomAttributeBuilder.cs
- Source:
- CustomAttributeBuilder.cs
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())
Parameters
- con
- ConstructorInfo
The constructor for the custom attribute.
- constructorArgs
- Object[]
The arguments to the constructor of the custom attribute.
- namedProperties
- PropertyInfo[]
Named properties of the custom attribute.
- propertyValues
- Object[]
Values for the named properties of the custom attribute.
Exceptions
The lengths of the namedProperties
and propertyValues
arrays are different.
-or-
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-
A property has no setter method.
-or-
The property does not belong to the same class or base class as the constructor.
-or-
A supplied argument or named property is a reference type other than String or Type.
One of the parameters is null
.
Remarks
The elements of the constructorArgs
and propertyValues
arrays are restricted to element types. 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.
Important
Do not include private properties in namedProperties
. Doing so will cause CustomAttributeFormatException to be thrown when the GetCustomAttributes method is later called on the completed type.
Applies to
CustomAttributeBuilder(ConstructorInfo, Object[], PropertyInfo[], Object[], FieldInfo[], Object[])
- Source:
- CustomAttributeBuilder.cs
- Source:
- CustomAttributeBuilder.cs
- Source:
- CustomAttributeBuilder.cs
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())
Parameters
- con
- ConstructorInfo
The constructor for the custom attribute.
- constructorArgs
- Object[]
The arguments to the constructor of the custom attribute.
- namedProperties
- PropertyInfo[]
Named properties of the custom attribute.
- propertyValues
- Object[]
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.
Exceptions
The lengths of the namedProperties
and propertyValues
arrays are different.
-or-
The lengths of the namedFields
and fieldValues
arrays are different.
-or-
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-
A property has no setter.
-or-
The property or field does not belong to the same class or base class as the constructor.
-or-
A supplied argument, named property, or named field is a reference type other than String or Type.
One of the parameters is null
.
Remarks
The elements of the constructorArgs
, propertyValues
, or fieldValues
arrays are restricted to element types. 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.
Important
Do not include private properties or fields in namedProperties
or namedFields
. Doing so will cause CustomAttributeFormatException to be thrown when the GetCustomAttributes method is later called on the completed type.