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

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

ModuleBuilder.CreateGlobalFunctions メソッド

この動的モジュールグローバル関数定義グローバル データ定義を完了します

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

Public Sub CreateGlobalFunctions
Dim instance As ModuleBuilder

instance.CreateGlobalFunctions
public void CreateGlobalFunctions ()
public:
void CreateGlobalFunctions ()
public void CreateGlobalFunctions ()
public function CreateGlobalFunctions ()
例外例外
例外種類条件

InvalidOperationException

このメソッドは、既に呼び出されています。

解説解説
使用例使用例

CreateGlobalFunctions使用して、DefineGlobalMethod で実装されている MethodBuilder から静的グローバル メソッド作成する方法次の例に示しますCreateGlobalFunctions は、DefineGlobalMethod使用して 1 つ上のグローバル メソッド実装した後に呼び出す必要があります

Dim currentDomain As AppDomain
Dim myAssemblyName As AssemblyName
Dim myMethodBuilder As MethodBuilder = Nothing
Dim myILGenerator As ILGenerator

' 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.RunAndSave)
' Define a dynamic module in "TempAssembly" assembly.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule")

' Define a global method in the 'TempModule' module.
myMethodBuilder = myModuleBuilder.DefineGlobalMethod("MyMethod1",
 MethodAttributes.Static _
                                          Or MethodAttributes.Public,
 Nothing, Nothing)
myILGenerator = myMethodBuilder.GetILGenerator()
myILGenerator.EmitWriteLine("Hello World from global method.")
myILGenerator.Emit(OpCodes.Ret)
' Fix up the 'TempModule' module .
myModuleBuilder.CreateGlobalFunctions()
AppDomain currentDomain;
AssemblyName myAssemblyName;
MethodBuilder myMethodBuilder=null;
ILGenerator myILGenerator;

// 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.RunAndSave);
// Define a dynamic module in "TempAssembly" assembly.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule");

// Define a global method in the 'TempModule' module.
myMethodBuilder = myModuleBuilder.DefineGlobalMethod
     ("MyMethod1",MethodAttributes.Static|MethodAttributes.Public,
           null,null);
myILGenerator = myMethodBuilder.GetILGenerator();
myILGenerator.EmitWriteLine("Hello World from global method.");
myILGenerator.Emit(OpCodes.Ret);
// Fix up the 'TempModule' module .
myModuleBuilder.CreateGlobalFunctions();
AppDomain^ currentDomain;
AssemblyName^ myAssemblyName;
MethodBuilder^ myMethodBuilder = nullptr;
ILGenerator^ myILGenerator;

// 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::RunAndSave );

// Define a dynamic module in "TempAssembly" assembly.
myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule"
 );

// Define a global method in the 'TempModule' module.
myMethodBuilder = myModuleBuilder->DefineGlobalMethod(
   "MyMethod1", (MethodAttributes)(MethodAttributes::Static | MethodAttributes::Public)
,
   nullptr, nullptr );
myILGenerator = myMethodBuilder->GetILGenerator();
myILGenerator->EmitWriteLine( "Hello World from global method." );
myILGenerator->Emit( OpCodes::Ret );

// Fix up the 'TempModule' module .
myModuleBuilder->CreateGlobalFunctions();
AppDomain currentDomain;
AssemblyName myAssemblyName;
MethodBuilder myMethodBuilder = null;
ILGenerator myILGenerator;

// 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.RunAndSave);

// Define a dynamic module in "TempAssembly" assembly.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule");

// Define a global method in the 'TempModule' module.
myMethodBuilder = myModuleBuilder.DefineGlobalMethod("MyMethod1",
    MethodAttributes.Static | MethodAttributes.Public, null, null);
myILGenerator = myMethodBuilder.GetILGenerator();
myILGenerator.EmitWriteLine("Hello World from global method.");
myILGenerator.Emit(OpCodes.Ret);

// Fix up the 'TempModule' module.
myModuleBuilder.CreateGlobalFunctions();
.NET Framework のセキュリティ.NET Frameworkセキュリティ
  • ReflectionPermission  SecurityAction.Demand、ReflectionEmit
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ModuleBuilder クラス
ModuleBuilder メンバ
System.Reflection.Emit 名前空間


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS