ModuleBuilder.DefineInitializedData メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ModuleBuilder.DefineInitializedData メソッドの意味・解説 

ModuleBuilder.DefineInitializedData メソッド

ポータブル実行可能 (PE) ファイルの .sdata セクション初期化済みデータ フィールド定義します

名前空間: System.Reflection.Emit
アセンブリ: 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,
    byte[] data,
    FieldAttributes attributes
)
public:
FieldBuilder^ DefineInitializedData (
    String^ name, 
    array<unsigned char>^ data, 
    FieldAttributes attributes
)
public FieldBuilder DefineInitializedData (
    String name, 
    byte[] data, 
    FieldAttributes attributes
)
public function DefineInitializedData (
    name : String, 
    data : byte[], 
    attributes : FieldAttributes
) : FieldBuilder

パラメータ

name

データ参照するために使用される名前。namenull埋め込むことはできません。

data

データBLOB

attributes

フィールド属性既定値Static です。

戻り値
データ参照するフィールド

例外例外
例外種類条件

ArgumentException

name長さが 0 です。

または

dataサイズが 0 以下か、0x3f0000 以上です。

ArgumentNullException

name または datanull 参照 (Visual Basic では Nothing) です。

InvalidOperationException

CreateGlobalFunctions は既に呼び出されています。

解説解説

Static は、自動的に attributes含まれます。

このメソッドによって定義されデータは、CreateGlobalFunctions メソッド呼び出されるまでは作成されません。

使用例使用例
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 のセキュリティ.NET Frameworkセキュリティ
  • ReflectionPermission  SecurityAction.Demand、ReflectionEmit
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ModuleBuilder クラス
ModuleBuilder メンバ
System.Reflection.Emit 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からModuleBuilder.DefineInitializedData メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からModuleBuilder.DefineInitializedData メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からModuleBuilder.DefineInitializedData メソッド を検索

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

辞書ショートカット

すべての辞書の索引

ModuleBuilder.DefineInitializedData メソッドのお隣キーワード
検索ランキング

   

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



ModuleBuilder.DefineInitializedData メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS