ModuleBuilder.DefineInitializedData メソッド
アセンブリ: mscorlib (mscorlib.dll 内)
構文Public Function DefineInitializedData ( _ name As String, _ data As Byte(), _ attributes As FieldAttributes _ ) As FieldBuilder
Dim instance As ModuleBuilder Dim name As String Dim data As Byte() Dim attributes As FieldAttributes Dim returnValue As FieldBuilder returnValue = instance.DefineInitializedData(name, data, attributes)
public: FieldBuilder^ DefineInitializedData ( String^ name, array<unsigned char>^ data, FieldAttributes attributes )
public function DefineInitializedData ( name : String, data : byte[], attributes : FieldAttributes ) : FieldBuilder
戻り値
データを参照するフィールド。
例外
解説
使用例Dim currentDomain As AppDomain Dim myAssemblyName As AssemblyName ' Get the current application domain for the current thread. currentDomain = AppDomain.CurrentDomain myAssemblyName = New AssemblyName() myAssemblyName.Name = "TempAssembly" ' Define a dynamic assembly in the 'currentDomain'. myAssemblyBuilder = _ currentDomain.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.Run) ' Define a dynamic module in "TempAssembly" assembly. myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule") ' Define the initialized data field in the .sdata section of the PE file. Dim myFieldBuilder As FieldBuilder = _ myModuleBuilder.DefineInitializedData("MyField", New Byte() {1, 0, 1}, _ FieldAttributes.Static Or FieldAttributes.Public) myModuleBuilder.CreateGlobalFunctions()
AppDomain currentDomain; AssemblyName myAssemblyName; // Get the current application domain for the current thread. currentDomain = AppDomain.CurrentDomain; myAssemblyName = new AssemblyName(); myAssemblyName.Name = "TempAssembly"; // Define a dynamic assembly in the 'currentDomain'. myAssemblyBuilder = currentDomain.DefineDynamicAssembly (myAssemblyName, AssemblyBuilderAccess.Run); // Define a dynamic module in "TempAssembly" assembly. myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule"); // Define the initialized data field in the .sdata section of the PE file. FieldBuilder myFieldBuilder = myModuleBuilder.DefineInitializedData("MyField",new byte[]{01,00,01}, FieldAttributes.Static|FieldAttributes.Public); myModuleBuilder.CreateGlobalFunctions();
AppDomain^ currentDomain; AssemblyName^ myAssemblyName; // Get the current application domain for the current thread. currentDomain = AppDomain::CurrentDomain; myAssemblyName = gcnew AssemblyName; myAssemblyName->Name = "TempAssembly"; // Define a dynamic assembly in the 'currentDomain'. myAssemblyBuilder = currentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); // Define a dynamic module in "TempAssembly" assembly. myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule" ); // Define the initialized data field in the .sdata section of the PE file. array<Byte>^ temp0 = {01,00,01}; FieldBuilder^ myFieldBuilder = myModuleBuilder->DefineInitializedData( "MyField", temp0, (FieldAttributes)(FieldAttributes::Static | FieldAttributes::Public) ); myModuleBuilder->CreateGlobalFunctions();
AppDomain currentDomain; AssemblyName myAssemblyName; // Get the current application domain for the current thread. currentDomain = AppDomain.get_CurrentDomain(); myAssemblyName = new AssemblyName(); myAssemblyName.set_Name("TempAssembly"); // Define a dynamic assembly in the 'currentDomain'. myAssemblyBuilder = currentDomain.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.Run); // Define a dynamic module in "TempAssembly" assembly. myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule"); // Define the initialized data field in the.sdata section // of the PE file. FieldBuilder myFieldBuilder = myModuleBuilder.DefineInitializedData( "MyField", new ubyte[] { 1, 0, 1 }, FieldAttributes.Static | FieldAttributes.Public); myModuleBuilder.CreateGlobalFunctions();
.NET Framework のセキュリティ- ReflectionPermission SecurityAction.Demand、ReflectionEmit
プラットフォームWindows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照- ModuleBuilder.DefineInitializedData メソッドのページへのリンク