_CustomAttributeBuilderとは? わかりやすく解説

CustomAttributeBuilder クラス

カスタム属性構築支援します

名前空間: System.Reflection.Emit
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.None)> _
Public Class CustomAttributeBuilder
    Implements _CustomAttributeBuilder
Dim instance As CustomAttributeBuilder
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType.None)] 
public class CustomAttributeBuilder : _CustomAttributeBuilder
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType::None)] 
public ref class CustomAttributeBuilder : _CustomAttributeBuilder
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.None) */ 
public class CustomAttributeBuilder implements
 _CustomAttributeBuilder
ComVisibleAttribute(true) 
ClassInterfaceAttribute(ClassInterfaceType.None) 
public class CustomAttributeBuilder implements
 _CustomAttributeBuilder
解説解説
メモメモ

このクラス適用される HostProtectionAttribute 属性Resources プロパティの値は、MayLeakOnAbort です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的にはアイコンダブルクリックコマンド入力、またはブラウザURL入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラストピックまたは「SQL Server プログラミングホスト保護属性」を参照してください

コンストラクタから返されCustomAttributeBuilder オブジェクト使用してカスタム属性記述しますSetCustomAttribute メソッドビルダ インスタンス対して呼び出すことで、CustomAttribute をそのビルダ インスタンス関連付けます。たとえば、AssemblyCultureAttribute のコンストラクタとその引数指定することで、CustomAttributeBuilder作成して AssemblyCultureAttributeインスタンス記述します次にAssemblyBuilder に対して SetCustomAttribute を呼び出すことで、関連付け作成します

使用例使用例

CustomAttributeBuilder使用方法については、次のコード例参照してください

Imports System
Imports System.Threading
Imports System.Reflection
Imports System.Reflection.Emit

 _


' We will apply this custom attribute to our dynamic type.
Public Class ClassCreator

   Inherits Attribute
   
   Private creator As String
   
   Public ReadOnly Property
 GetCreator() As String
      Get
         Return creator
      End Get
   End Property
   
   
   Public Sub New(name As
 String)
      Me.creator = name
   End Sub 'New

End Class 'ClassCreator
 _ 

' We will apply this dynamic attribute to our dynamic method.
Public Class DateLastUpdated

   Inherits Attribute
   
   Private dateUpdated As String
   
   Public ReadOnly Property
 GetDateUpdated() As String
      Get
         Return dateUpdated
      End Get
   End Property
   
   
   Public Sub New(theDate
 As String)
      Me.dateUpdated = theDate
   End Sub 'New

End Class 'DateLastUpdated
 _ 

Class MethodBuilderCustomAttributesDemo
   
   Public Shared Function
 BuildTypeWithCustomAttributesOnMethod() As Type
      
      Dim currentDomain As AppDomain = Thread.GetDomain()
      
      Dim myAsmName As New
 AssemblyName()
      myAsmName.Name = "MyAssembly"
      
      Dim myAsmBuilder As AssemblyBuilder =
 currentDomain.DefineDynamicAssembly(myAsmName, _
                            AssemblyBuilderAccess.Run)
      
      Dim myModBuilder As ModuleBuilder = myAsmBuilder.DefineDynamicModule("MyModule")
      
      ' First, we'll build a type with a custom attribute attached.
      Dim myTypeBuilder As TypeBuilder = myModBuilder.DefineType("MyType",
 _
                            TypeAttributes.Public)
      
      Dim ctorParams() As Type = {GetType(String)}
      Dim classCtorInfo As ConstructorInfo
 = GetType(ClassCreator).GetConstructor(ctorParams)
      
      Dim myCABuilder As New
 CustomAttributeBuilder(classCtorInfo, _
                        New Object() {"Joe
 Programmer"})
      
      myTypeBuilder.SetCustomAttribute(myCABuilder)
      
      ' Now, let's build a method and add a custom attribute to it.
      Dim myMethodBuilder As MethodBuilder
 = myTypeBuilder.DefineMethod("HelloWorld", _
                    MethodAttributes.Public, Nothing, New
 Type() {})
      
      ctorParams = New Type() {GetType(String)}
      classCtorInfo = GetType(DateLastUpdated).GetConstructor(ctorParams)
      
      Dim myCABuilder2 As New
 CustomAttributeBuilder(classCtorInfo, _
                        New Object() {DateTime.Now.ToString()})
      
      myMethodBuilder.SetCustomAttribute(myCABuilder2)
      
      Dim myIL As ILGenerator = myMethodBuilder.GetILGenerator()
      
      myIL.EmitWriteLine("Hello, world!")
      myIL.Emit(OpCodes.Ret)
      
      Return myTypeBuilder.CreateType()

   End Function 'BuildTypeWithCustomAttributesOnMethod
    
   
   Public Shared Sub Main()
      
      Dim myType As Type = BuildTypeWithCustomAttributesOnMethod()
      
      Dim myInstance As Object
 = Activator.CreateInstance(myType)
      
      Dim customAttrs As Object()
 = myType.GetCustomAttributes(True)
      
      Console.WriteLine("Custom Attributes for Type 'MyType':")
      
      Dim attrVal As Object
 = Nothing
      
      Dim customAttr As Object
      For Each customAttr In
  customAttrs
         attrVal = GetType(ClassCreator).InvokeMember("GetCreator",
 _
                        BindingFlags.GetProperty, _
                        Nothing, customAttr, New
 Object() {})
         Console.WriteLine("-- Attribute: [{0} = ""{1}""]",
 customAttr, attrVal)
      Next customAttr
      
      Console.WriteLine("Custom Attributes for Method 'HelloWorld()'
 in 'MyType':")
      
      customAttrs = myType.GetMember("HelloWorld")(0).GetCustomAttributes(True)
      
      For Each customAttr In
  customAttrs
         attrVal = GetType(DateLastUpdated).InvokeMember("GetDateUpdated",
 _
                        BindingFlags.GetProperty, _
                        Nothing, customAttr, New
 Object() {})
         Console.WriteLine("-- Attribute: [{0} = ""{1}""]",
 customAttr, attrVal)
      Next customAttr
      
      Console.WriteLine("---")
      
      Console.WriteLine(myType.InvokeMember("HelloWorld",
 BindingFlags.InvokeMethod, _
                        Nothing, myInstance, New
 Object() {}))
   End Sub 'Main

End Class 'MethodBuilderCustomAttributesDemo

using System;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;


// We will apply this custom attribute to our dynamic type.
public class ClassCreator: Attribute

{
   private string creator;
   public string Creator 
   {
    get
    {
       return creator;
    }
   }    

   public ClassCreator(string name)
   {
      this.creator = name;
   }

}

// We will apply this dynamic attribute to our dynamic method.
public class DateLastUpdated: Attribute

{
   private string dateUpdated;
   public string DateUpdated
   {
       get
    {
       return dateUpdated;
    }
   }

   public DateLastUpdated(string theDate)
   {
    this.dateUpdated = theDate;
   } 

}

class MethodBuilderCustomAttributesDemo

{

   public static Type BuildTypeWithCustomAttributesOnMethod()
   {
    
    AppDomain currentDomain = Thread.GetDomain();
    
    AssemblyName myAsmName = new AssemblyName();
    myAsmName.Name = "MyAssembly";

    AssemblyBuilder myAsmBuilder = currentDomain.DefineDynamicAssembly(
                       myAsmName, AssemblyBuilderAccess.Run);

    ModuleBuilder myModBuilder = myAsmBuilder.DefineDynamicModule("MyModule");

    // First, we'll build a type with a custom attribute attached.

    TypeBuilder myTypeBuilder = myModBuilder.DefineType("MyType",
                        TypeAttributes.Public);
    
    Type[] ctorParams = new Type[] { typeof(string)
 };
    ConstructorInfo classCtorInfo = typeof(ClassCreator).GetConstructor(ctorParams);

    CustomAttributeBuilder myCABuilder = new CustomAttributeBuilder(
                        classCtorInfo,
                        new object[] { "Joe Programmer"
 });

    myTypeBuilder.SetCustomAttribute(myCABuilder);

    // Now, let's build a method and add a custom attribute to it.

    MethodBuilder myMethodBuilder = myTypeBuilder.DefineMethod("HelloWorld"
,
                    MethodAttributes.Public,
                    null,
                    new Type[] { });

    ctorParams = new Type[] { typeof(string)
 };
    classCtorInfo = typeof(DateLastUpdated).GetConstructor(ctorParams);

    CustomAttributeBuilder myCABuilder2 = new CustomAttributeBuilder(
                        classCtorInfo,
                        new object[] { DateTime.Now.ToString()
 });

    myMethodBuilder.SetCustomAttribute(myCABuilder2);

    ILGenerator myIL = myMethodBuilder.GetILGenerator();

    myIL.EmitWriteLine("Hello, world!");
    myIL.Emit(OpCodes.Ret);

    return myTypeBuilder.CreateType();
    
   }

   public static void Main()
 
   {

    Type myType = BuildTypeWithCustomAttributesOnMethod();

    object myInstance = Activator.CreateInstance(myType);

    object[] customAttrs = myType.GetCustomAttributes(true);

    Console.WriteLine("Custom Attributes for Type 'MyType':");

    object attrVal = null;

    foreach (object customAttr in customAttrs)
 
       {
       attrVal = typeof(ClassCreator).InvokeMember("Creator", 
                      BindingFlags.GetProperty,
                      null, customAttr, new
 object[] { });
       Console.WriteLine("-- Attribute: [{0} = \"{1}\"]", customAttr,
 attrVal);
        }

    Console.WriteLine("Custom Attributes for Method 'HelloWorld()'
 in 'MyType':");

    customAttrs = myType.GetMember("HelloWorld")[0].GetCustomAttributes(true);
    

    foreach (object customAttr in customAttrs)
 
       {
       attrVal = typeof(DateLastUpdated).InvokeMember("DateUpdated", 
                      BindingFlags.GetProperty,
                      null, customAttr, new
 object[] { });
       Console.WriteLine("-- Attribute: [{0} = \"{1}\"]", customAttr,
 attrVal);
        }

    Console.WriteLine("---");

    Console.WriteLine(myType.InvokeMember("HelloWorld",
              BindingFlags.InvokeMethod,
              null, myInstance, new object[]
 { }));
                           
    
   }

}

using namespace System;
using namespace System::Threading;
using namespace System::Reflection;
using namespace System::Reflection::Emit;

// We will apply this custom attribute to our dynamic type.
public ref class ClassCreator: public
 Attribute
{
private:
   String^ creator;

public:

   property String^ Creator 
   {
      String^ get()
      {
         return creator;
      }

   }
   ClassCreator( String^ name )
   {
      this->creator = name;
   }

};


// We will apply this dynamic attribute to our dynamic method.
public ref class DateLastUpdated: public
 Attribute
{
private:
   String^ dateUpdated;

public:

   property String^ DateUpdated 
   {
      String^ get()
      {
         return dateUpdated;
      }

   }
   DateLastUpdated( String^ theDate )
   {
      this->dateUpdated = theDate;
   }

};

Type^ BuildTypeWithCustomAttributesOnMethod()
{
   AppDomain^ currentDomain = Thread::GetDomain();
   AssemblyName^ myAsmName = gcnew AssemblyName;
   myAsmName->Name = "MyAssembly";
   AssemblyBuilder^ myAsmBuilder = currentDomain->DefineDynamicAssembly( myAsmName,
 AssemblyBuilderAccess::Run );
   ModuleBuilder^ myModBuilder = myAsmBuilder->DefineDynamicModule( "MyModule"
 );
   
   // First, we'll build a type with a custom attribute attached.
   TypeBuilder^ myTypeBuilder = myModBuilder->DefineType( "MyType",
 TypeAttributes::Public );
   array<Type^>^temp6 = {String::typeid};
   array<Type^>^ctorParams = temp6;
   ConstructorInfo^ classCtorInfo = ClassCreator::typeid->GetConstructor( ctorParams
 );
   array<Object^>^temp0 = {"Joe Programmer"};
   CustomAttributeBuilder^ myCABuilder = gcnew CustomAttributeBuilder( classCtorInfo,temp0
 );
   myTypeBuilder->SetCustomAttribute( myCABuilder );
   
   // Now, let's build a method and add a custom attribute to it.
   array<Type^>^temp1 = gcnew array<Type^>(0);
   MethodBuilder^ myMethodBuilder = myTypeBuilder->DefineMethod( "HelloWorld",
 MethodAttributes::Public, nullptr, temp1 );
   array<Type^>^temp7 = {String::typeid};
   ctorParams = temp7;
   classCtorInfo = DateLastUpdated::typeid->GetConstructor( ctorParams );
   array<Object^>^temp2 = {DateTime::Now.ToString()};
   CustomAttributeBuilder^ myCABuilder2 = gcnew CustomAttributeBuilder( classCtorInfo,temp2
 );
   myMethodBuilder->SetCustomAttribute( myCABuilder2 );
   ILGenerator^ myIL = myMethodBuilder->GetILGenerator();
   myIL->EmitWriteLine( "Hello, world!" );
   myIL->Emit( OpCodes::Ret );
   return myTypeBuilder->CreateType();
}

int main()
{
   Type^ myType = BuildTypeWithCustomAttributesOnMethod();
   Object^ myInstance = Activator::CreateInstance( myType );
   array<Object^>^customAttrs = myType->GetCustomAttributes( true
 );
   Console::WriteLine( "Custom Attributes for Type 'MyType':"
 );
   Object^ attrVal = nullptr;
   System::Collections::IEnumerator^ myEnum = customAttrs->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      Object^ customAttr = safe_cast<Object^>(myEnum->Current);
      array<Object^>^temp3 = gcnew array<Object^>(0);
      attrVal = ClassCreator::typeid->InvokeMember( "Creator", BindingFlags::GetProperty,
 nullptr, customAttr, temp3 );
      Console::WriteLine( "-- Attribute: [{0} = \"{1}\"]", customAttr,
 attrVal );
   }

   Console::WriteLine( "Custom Attributes for Method 'HelloWorld()'
 in 'MyType':" );
   customAttrs = myType->GetMember( "HelloWorld" )[ 0 ]->GetCustomAttributes(
 true );
   System::Collections::IEnumerator^ myEnum2 = customAttrs->GetEnumerator();
   while ( myEnum2->MoveNext() )
   {
      Object^ customAttr = safe_cast<Object^>(myEnum2->Current);
      array<Object^>^temp4 = gcnew array<Object^>(0);
      attrVal = DateLastUpdated::typeid->InvokeMember( "DateUpdated",
 BindingFlags::GetProperty, nullptr, customAttr, temp4 );
      Console::WriteLine( "-- Attribute: [{0} = \"{1}\"]", customAttr,
 attrVal );
   }

   Console::WriteLine( "---" );
   array<Object^>^temp5 = gcnew array<Object^>(0);
   Console::WriteLine( myType->InvokeMember( "HelloWorld", BindingFlags::InvokeMethod,
 nullptr, myInstance, temp5 ) );
}
import System.*;
import System.Threading.*;
import System.Reflection.*;
import System.Reflection.Emit.*;

// We will apply this custom attribute to our dynamic type.
public class ClassCreator extends Attribute
{
    private String creator;

    /** @property 
     */
    public String get_Creator()
    {
        return creator ;
    } //get_Creator

    public ClassCreator(String name) 
    {
        this.creator = name;
    } //ClassCreator
} //ClassCreator

// We will apply this dynamic attribute to our dynamic method.
public class DateLastUpdated extends Attribute
{
    private String dateUpdated;
    /** @property 
     */
    public String get_DateUpdated()
    {
        return dateUpdated ;
    } //get_DateUpdated

    public DateLastUpdated(String theDate) 
    {
        this.dateUpdated = theDate;
    } //DateLastUpdated
} //DateLastUpdated

class MethodBuilderCustomAttributesDemo
{
    public static Type BuildTypeWithCustomAttributesOnMethod()
 
    {
        AppDomain currentDomain = System.Threading.Thread.GetDomain();
        AssemblyName myAsmName = new AssemblyName();
        myAsmName.set_Name("MyAssembly");
        AssemblyBuilder myAsmBuilder = currentDomain.DefineDynamicAssembly(
            myAsmName, AssemblyBuilderAccess.Run);
        ModuleBuilder myModBuilder =
            myAsmBuilder.DefineDynamicModule("MyModule");
        // First, we'll build a type with a custom attribute attached.
        TypeBuilder myTypeBuilder = myModBuilder.DefineType(
            "MyType", TypeAttributes.Public);
        Type ctorParams[] = new Type[]{String.class.ToType()};
        ConstructorInfo classCtorInfo = 
            ClassCreator.class.ToType().GetConstructor(ctorParams);
        CustomAttributeBuilder myCABuilder =  
            new CustomAttributeBuilder(classCtorInfo,
            new Object[]{"Joe Programmer"});
        myTypeBuilder.SetCustomAttribute(myCABuilder);

        // Now, let's build a method and add a custom attribute to it.
        MethodBuilder myMethodBuilder = myTypeBuilder.DefineMethod(
            "HelloWorld", MethodAttributes.Public, null,
 new Type[]{});
        ctorParams = new Type[]{String.class.ToType()};
        classCtorInfo =
            DateLastUpdated.class.ToType().GetConstructor(ctorParams);
        CustomAttributeBuilder myCABuilder2 = new CustomAttributeBuilder(
            classCtorInfo, new Object[]{DateTime.get_Now().ToString()});
        myMethodBuilder.SetCustomAttribute(myCABuilder2);
        ILGenerator myIL = myMethodBuilder.GetILGenerator();
        myIL.EmitWriteLine("Hello, world!");
        myIL.Emit(OpCodes.Ret);      
        return myTypeBuilder.CreateType() ;
    } //BuildTypeWithCustomAttributesOnMethod

    public static void main(String[]
 args)
    {
        Type myType = BuildTypeWithCustomAttributesOnMethod();      
        Object myInstance = Activator.CreateInstance(myType);      
        Object customAttrs[] = myType.GetCustomAttributes(true);
      
        Console.WriteLine("Custom Attributes for Type 'MyType':");
      
        Object attrVal = null;
        for (int iCtr=0; iCtr < customAttrs.length;
 iCtr++) {
            Object customAttr = customAttrs[iCtr];
            attrVal = ClassCreator.class.ToType().InvokeMember
                ("Creator", BindingFlags.GetProperty, null,
 customAttr,
                new Object[] {});
            Console.WriteLine(
                "-- Attribute: [{0} = \"{1}\"]", customAttr,attrVal);
        }      
        Console.WriteLine(
            "Custom Attributes for Method 'HelloWorld()'
 in 'MyType':");      
        customAttrs =
            myType.GetMember("HelloWorld")[0].GetCustomAttributes(true);
        for(int iCtr = 0; iCtr < customAttrs.length;
 iCtr++) {
            Object customAttr = customAttrs[iCtr];
            attrVal = DateLastUpdated.class.ToType().InvokeMember(
                "DateUpdated", BindingFlags.GetProperty, null,
 
                customAttr, new Object[] {});
            Console.WriteLine(
                "-- Attribute: [{0} = \"{1}\"]",customAttr, attrVal);
        }      
        Console.WriteLine("---");      
        Console.WriteLine(myType.InvokeMember(
            "HelloWorld", BindingFlags.InvokeMethod, null,
 
            myInstance, new Object[] {}));
    } //main
} //MethodBuilderCustomAttributesDemo
継承階層継承階層
System.Object
  System.Reflection.Emit.CustomAttributeBuilder
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CustomAttributeBuilder メンバ
System.Reflection.Emit 名前空間

CustomAttributeBuilder コンストラクタ (ConstructorInfo, Object[])

カスタム属性コンストラクタ、およびそのコンストラクタ引数指定してCustomAttributeBuilder クラスインスタンス初期化します。

名前空間: System.Reflection.Emit
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    con As ConstructorInfo, _
    constructorArgs As Object() _
)
Dim con As ConstructorInfo
Dim constructorArgs As Object()

Dim instance As New CustomAttributeBuilder(con,
 constructorArgs)
public CustomAttributeBuilder (
    ConstructorInfo con,
    Object[] constructorArgs
)
public:
CustomAttributeBuilder (
    ConstructorInfo^ con, 
    array<Object^>^ constructorArgs
)
public CustomAttributeBuilder (
    ConstructorInfo con, 
    Object[] constructorArgs
)
public function CustomAttributeBuilder (
    con : ConstructorInfo, 
    constructorArgs : Object[]
)

パラメータ

con

カスタム属性用のコンストラクタ

constructorArgs

カスタム属性コンストラクタに渡す引数

例外例外
例外種類条件

ArgumentException

con静的またはプライベートです。

または

指定され引数の数が、コンストラクタ呼び出し規約で必要とされるコンストラクタパラメータの数と一致しません。

または

指定され引数の型が、コンストラクタ内で宣言されパラメータの型と一致しません。

ArgumentNullException

conconstructorArgs、または constructorArgs 配列いずれか要素null 参照 (Visual Basic では Nothing) です。

解説解説

constructorArgs 配列要素は、要素型に制約されます。bytesbyteintuintlongulongfloatdoubleStringcharboolenumtype、これらの型のうちオブジェクトキャストされた任意の型、これらの型のインデックス番号が 0 から始まる 1 次元配列のいずれでもかまいません

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CustomAttributeBuilder クラス
CustomAttributeBuilder メンバ
System.Reflection.Emit 名前空間

CustomAttributeBuilder コンストラクタ (ConstructorInfo, Object[], PropertyInfo[], Object[], FieldInfo[], Object[])

カスタム属性コンストラクタ、そのコンストラクタ引数、名前付プロパティまたは値のペアセット、および名前付フィールドまたは値のペアセット指定してCustomAttributeBuilder クラスインスタンス初期化します。

名前空間: System.Reflection.Emit
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    con As ConstructorInfo, _
    constructorArgs As Object(), _
    namedProperties As PropertyInfo(), _
    propertyValues As Object(), _
    namedFields As FieldInfo(), _
    fieldValues As Object() _
)
Dim con As ConstructorInfo
Dim constructorArgs As Object()
Dim namedProperties As PropertyInfo()
Dim propertyValues As Object()
Dim namedFields As FieldInfo()
Dim fieldValues As Object()

Dim instance As New CustomAttributeBuilder(con,
 constructorArgs, namedProperties, propertyValues, namedFields, fieldValues)
public CustomAttributeBuilder (
    ConstructorInfo con,
    Object[] constructorArgs,
    PropertyInfo[] namedProperties,
    Object[] propertyValues,
    FieldInfo[] namedFields,
    Object[] fieldValues
)
public:
CustomAttributeBuilder (
    ConstructorInfo^ con, 
    array<Object^>^ constructorArgs, 
    array<PropertyInfo^>^ namedProperties, 
    array<Object^>^ propertyValues, 
    array<FieldInfo^>^ namedFields, 
    array<Object^>^ fieldValues
)
public CustomAttributeBuilder (
    ConstructorInfo con, 
    Object[] constructorArgs, 
    PropertyInfo[] namedProperties, 
    Object[] propertyValues, 
    FieldInfo[] namedFields, 
    Object[] fieldValues
)
public function CustomAttributeBuilder (
    con : ConstructorInfo, 
    constructorArgs : Object[], 
    namedProperties : PropertyInfo[], 
    propertyValues : Object[], 
    namedFields : FieldInfo[], 
    fieldValues : Object[]
)

パラメータ

con

カスタム属性用のコンストラクタ

constructorArgs

カスタム属性コンストラクタに渡す引数

namedProperties

カスタム属性の名前付プロパティ

propertyValues

カスタム属性の名前付プロパティの値。

namedFields

カスタム属性の名前付フィールド

fieldValues

カスタム属性の名前付フィールドの値。

例外例外
例外種類条件

ArgumentException

namedProperties 配列propertyValues 配列長さ違います

または

namedFieldsnamedValues長さ違います

または

con静的またはプライベートです。

または

指定され引数の数が、コンストラクタ呼び出し規約で必要とされるコンストラクタパラメータの数と一致しません。

または

指定され引数の型が、コンストラクタ内で宣言されパラメータの型と一致しません。

または

プロパティ値の型が名前付プロパティの型と一致しません。

または

フィールド値の型が対応するフィールド型の型と一致しません。

または

プロパティ設定メソッドがありません。

または

プロパティまたはフィールドが、コンストラクタと同じクラスまたは基本クラス属していません。

ArgumentNullException

パラメータまたは配列パラメータ要素いずれかnull 参照 (Visual Basic では Nothing) です。

解説解説

constructorArgspropertyValues または fieldValues 配列要素は、要素型に制約されます。bytesbyteintuintlongulongfloatdoubleStringcharboolenumtype、これらの型のうちオブジェクトキャストされた任意の型、これらの型のインデックス番号が 0 から始まる 1 次元配列のいずれでもかまいません

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CustomAttributeBuilder クラス
CustomAttributeBuilder メンバ
System.Reflection.Emit 名前空間

CustomAttributeBuilder コンストラクタ (ConstructorInfo, Object[], PropertyInfo[], Object[])

カスタム属性コンストラクタ、そのコンストラクタ引数、および名前付プロパティまたは値のペアセット指定してCustomAttributeBuilder クラスインスタンス初期化します。

名前空間: System.Reflection.Emit
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    con As ConstructorInfo, _
    constructorArgs As Object(), _
    namedProperties As PropertyInfo(), _
    propertyValues As Object() _
)
Dim con As ConstructorInfo
Dim constructorArgs As Object()
Dim namedProperties As PropertyInfo()
Dim propertyValues As Object()

Dim instance As New CustomAttributeBuilder(con,
 constructorArgs, namedProperties, propertyValues)
public CustomAttributeBuilder (
    ConstructorInfo con,
    Object[] constructorArgs,
    PropertyInfo[] namedProperties,
    Object[] propertyValues
)
public:
CustomAttributeBuilder (
    ConstructorInfo^ con, 
    array<Object^>^ constructorArgs, 
    array<PropertyInfo^>^ namedProperties, 
    array<Object^>^ propertyValues
)
public CustomAttributeBuilder (
    ConstructorInfo con, 
    Object[] constructorArgs, 
    PropertyInfo[] namedProperties, 
    Object[] propertyValues
)
public function CustomAttributeBuilder (
    con : ConstructorInfo, 
    constructorArgs : Object[], 
    namedProperties : PropertyInfo[], 
    propertyValues : Object[]
)

パラメータ

con

カスタム属性用のコンストラクタ

constructorArgs

カスタム属性コンストラクタに渡す引数

namedProperties

カスタム属性の名前付プロパティ

propertyValues

カスタム属性の名前付プロパティの値。

例外例外
例外種類条件

ArgumentException

namedProperties 配列propertyValues 配列長さ違います

または

con静的またはプライベートです。

または

指定され引数の数が、コンストラクタ呼び出し規約で必要とされるコンストラクタパラメータの数と一致しません。

または

指定され引数の型が、コンストラクタ内で宣言されパラメータの型と一致しません。

または

プロパティ値の型が名前付プロパティの型と一致しません。

または

プロパティ設定メソッドがありません。

または

プロパティが、コンストラクタと同じクラスまたは基本クラス属していません。

ArgumentNullException

パラメータいずれかnull です。または、配列パラメータ要素いずれかnull 参照 (Visual Basic では Nothing) です。

解説解説

constructorArgs 配列および propertyValues 配列要素は、要素型に制約されます。bytesbyteintuintlongulongfloatdoubleStringcharboolenumtype、これらの型のうちオブジェクトキャストされた任意の型、これらの型のインデックス番号が 0 から始まる 1 次元配列のいずれでもかまいません

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CustomAttributeBuilder クラス
CustomAttributeBuilder メンバ
System.Reflection.Emit 名前空間

CustomAttributeBuilder コンストラクタ (ConstructorInfo, Object[], FieldInfo[], Object[])

カスタム属性コンストラクタ、そのコンストラクタ引数、および名前付フィールドと値のペアセット指定してCustomAttributeBuilder クラスインスタンス初期化します。

名前空間: System.Reflection.Emit
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    con As ConstructorInfo, _
    constructorArgs As Object(), _
    namedFields As FieldInfo(), _
    fieldValues As Object() _
)
Dim con As ConstructorInfo
Dim constructorArgs As Object()
Dim namedFields As FieldInfo()
Dim fieldValues As Object()

Dim instance As New CustomAttributeBuilder(con,
 constructorArgs, namedFields, fieldValues)
public CustomAttributeBuilder (
    ConstructorInfo con,
    Object[] constructorArgs,
    FieldInfo[] namedFields,
    Object[] fieldValues
)
public:
CustomAttributeBuilder (
    ConstructorInfo^ con, 
    array<Object^>^ constructorArgs, 
    array<FieldInfo^>^ namedFields, 
    array<Object^>^ fieldValues
)
public CustomAttributeBuilder (
    ConstructorInfo con, 
    Object[] constructorArgs, 
    FieldInfo[] namedFields, 
    Object[] fieldValues
)
public function CustomAttributeBuilder (
    con : ConstructorInfo, 
    constructorArgs : Object[], 
    namedFields : FieldInfo[], 
    fieldValues : Object[]
)

パラメータ

con

カスタム属性用のコンストラクタ

constructorArgs

カスタム属性コンストラクタに渡す引数

namedFields

カスタム属性の名前付フィールド

fieldValues

カスタム属性の名前付フィールドの値。

例外例外
例外種類条件

ArgumentException

namedFields 配列fieldValues 配列長さ違います

または

con静的またはプライベートです。

または

指定され引数の数が、コンストラクタ呼び出し規約で必要とされるコンストラクタパラメータの数と一致しません。

または

指定され引数の型が、コンストラクタ内で宣言されパラメータの型と一致しません。

または

フィールド値の型が名前付フィールドの型と一致しません。

または

フィールドが、コンストラクタと同じクラスまたは基本クラス属していません。

ArgumentNullException

パラメータまたは配列パラメータ要素いずれかnull 参照 (Visual Basic では Nothing) です。

解説解説

constructorArgs 配列および fieldValues 配列要素は、要素型に制約されます。bytesbyteintuintlongulongfloatdoubleStringcharboolenumtype、これらの型のうちオブジェクトキャストされた任意の型、これらの型のインデックス番号が 0 から始まる 1 次元配列のいずれでもかまいません

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CustomAttributeBuilder クラス
CustomAttributeBuilder メンバ
System.Reflection.Emit 名前空間

CustomAttributeBuilder コンストラクタ

CustomAttributeBuilder クラスインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
CustomAttributeBuilder (ConstructorInfo, Object[]) カスタム属性コンストラクタ、およびそのコンストラクタ引数指定してCustomAttributeBuilder クラスインスタンス初期化します。
CustomAttributeBuilder (ConstructorInfo, Object[], FieldInfo[], Object[]) カスタム属性コンストラクタ、そのコンストラクタ引数、および名前付フィールドと値のペアセット指定してCustomAttributeBuilder クラスインスタンス初期化します。
CustomAttributeBuilder (ConstructorInfo, Object[], PropertyInfo[], Object[]) カスタム属性コンストラクタ、そのコンストラクタ引数、および名前付プロパティまたは値のペアセット指定してCustomAttributeBuilder クラスインスタンス初期化します。
CustomAttributeBuilder (ConstructorInfo, Object[], PropertyInfo[], Object[], FieldInfo[], Object[]) カスタム属性コンストラクタ、そのコンストラクタ引数、名前付プロパティまたは値のペアセット、および名前付フィールドまたは値のペアセット指定してCustomAttributeBuilder クラスインスタンス初期化します。
参照参照

関連項目

CustomAttributeBuilder クラス
CustomAttributeBuilder メンバ
System.Reflection.Emit 名前空間

CustomAttributeBuilder メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Runtime.InteropServices._CustomAttributeBuilder.GetIDsOfNames 名前のセット対応するディスパッチ識別子セット割り当てます
インターフェイスの明示的な実装 System.Runtime.InteropServices._CustomAttributeBuilder.GetTypeInfo オブジェクト型情報取得します。この型情報は、インターフェイス型情報取得するために使用できます
インターフェイスの明示的な実装 System.Runtime.InteropServices._CustomAttributeBuilder.GetTypeInfoCount オブジェクト提供する型情報インターフェイスの数を取得します (0 または 1)。
インターフェイスの明示的な実装 System.Runtime.InteropServices._CustomAttributeBuilder.Invoke オブジェクトによって公開されているプロパティおよびメソッドアクセスできるようにします。
参照参照

関連項目

CustomAttributeBuilder クラス
System.Reflection.Emit 名前空間

CustomAttributeBuilder メンバ

カスタム属性構築支援します

CustomAttributeBuilder データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド CustomAttributeBuilder オーバーロードされますCustomAttributeBuilder クラスインスタンス初期化します。
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Runtime.InteropServices._CustomAttributeBuilder.GetIDsOfNames 名前のセット対応するディスパッチ識別子セット割り当てます
インターフェイスの明示的な実装 System.Runtime.InteropServices._CustomAttributeBuilder.GetTypeInfo オブジェクト型情報取得します。この型情報は、インターフェイス型情報取得するために使用できます
インターフェイスの明示的な実装 System.Runtime.InteropServices._CustomAttributeBuilder.GetTypeInfoCount オブジェクト提供する型情報インターフェイスの数を取得します (0 または 1)。
インターフェイスの明示的な実装 System.Runtime.InteropServices._CustomAttributeBuilder.Invoke オブジェクトによって公開されているプロパティおよびメソッドアクセスできるようにします。
参照参照

関連項目

CustomAttributeBuilder クラス
System.Reflection.Emit 名前空間

_CustomAttributeBuilder インターフェイス

メモ : このインターフェイスは、.NET Framework version 2.0新しく追加されたものです。

System.Reflection.Emit.CustomAttributeBuilder クラスアンマネージ コード公開します

 

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<GuidAttribute("BE9ACCE8-AAFF-3B91-81AE-8211663F5CAD")>
 _
<ComVisibleAttribute(True)> _
<InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _
<CLSCompliantAttribute(False)> _
Public Interface _CustomAttributeBuilder
Dim instance As _CustomAttributeBuilder
[GuidAttribute("BE9ACCE8-AAFF-3B91-81AE-8211663F5CAD")] 
[ComVisibleAttribute(true)] 
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] 
[CLSCompliantAttribute(false)] 
public interface _CustomAttributeBuilder
[GuidAttribute(L"BE9ACCE8-AAFF-3B91-81AE-8211663F5CAD")] 
[ComVisibleAttribute(true)] 
[InterfaceTypeAttribute(ComInterfaceType::InterfaceIsIUnknown)] 
[CLSCompliantAttribute(false)] 
public interface class _CustomAttributeBuilder
/** @attribute GuidAttribute("BE9ACCE8-AAFF-3B91-81AE-8211663F5CAD") */
 
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown) */ 
/** @attribute CLSCompliantAttribute(false) */ 
public interface _CustomAttributeBuilder
GuidAttribute("BE9ACCE8-AAFF-3B91-81AE-8211663F5CAD") 
ComVisibleAttribute(true) 
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown) 
CLSCompliantAttribute(false) 
public interface _CustomAttributeBuilder
解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
_CustomAttributeBuilder メンバ
System.Runtime.InteropServices 名前空間

_CustomAttributeBuilder メソッド


_CustomAttributeBuilder メンバ

System.Reflection.Emit.CustomAttributeBuilder クラスアンマネージ コード公開します

_CustomAttributeBuilder データ型公開されるメンバを以下の表に示します


パブリック メソッドパブリック メソッド
参照参照

関連項目

_CustomAttributeBuilder インターフェイス
System.Runtime.InteropServices 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「_CustomAttributeBuilder」の関連用語

_CustomAttributeBuilderのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



_CustomAttributeBuilderのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS