ConstructorBuilder.SetSymCustomAttribute(String, Byte[]) メソッド

定義

シンボル情報に関連付けられているこのコンストラクターのカスタム属性を設定します。

C#
public void SetSymCustomAttribute(string name, byte[] data);

パラメーター

name
String

カスタム属性の名前。

data
Byte[]

カスタム属性の値。

例外

含んでいる型は CreateType() を使用して作成されています。

- または -

モジュールに、シンボルのライターが定義されていません。 たとえば、モジュールがデバッグ モジュールではありません。

注釈

次のコード サンプルは、 の SetSymCustomAttributes使用方法を示しています。

C#
MethodBuilder myMethodBuilder = null;
AppDomain myCurrentDomain = AppDomain.CurrentDomain;
// Create assembly in current CurrentDomain.
AssemblyName myAssemblyName = new AssemblyName();
myAssemblyName.Name = "TempAssembly";
// Create a dynamic assembly.
myAssemblyBuilder = myCurrentDomain.DefineDynamicAssembly
         (myAssemblyName, AssemblyBuilderAccess.Run);
// Create a dynamic module in the assembly.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule",true);
FieldInfo myFieldInfo =
   myModuleBuilder.DefineUninitializedData("myField", 2, FieldAttributes.Public);
// Create a type in the module.
TypeBuilder myTypeBuilder = myModuleBuilder.DefineType("TempClass",TypeAttributes.Public);
FieldBuilder myGreetingField = myTypeBuilder.DefineField("Greeting",
                                    typeof(String), FieldAttributes.Public);
Type[] myConstructorArgs = { typeof(String) };
// Define a constructor of the dynamic class.
ConstructorBuilder myConstructor = myTypeBuilder.DefineConstructor(
MethodAttributes.Public, CallingConventions.Standard, myConstructorArgs);
// Display the name of the constructor.
Console.WriteLine("The constructor name is  : "+ myConstructor.Name);
myConstructor.SetSymCustomAttribute("MySimAttribute", new byte[]{01,00,00});

適用対象

製品 バージョン
.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