ModuleBuilder.CreateGlobalFunctions Yöntem

Tanım

Bu dinamik modül için genel işlev tanımlarını ve genel veri tanımlarını tamamlar.

public:
 void CreateGlobalFunctions();
public void CreateGlobalFunctions();
member this.CreateGlobalFunctions : unit -> unit
Public Sub CreateGlobalFunctions ()

Özel durumlar

Bu yöntem daha önce çağrıldı.

Örnekler

Aşağıdaki örnek, ile CreateGlobalFunctionsuygulanan bir 'den MethodBuilder statik genel yöntem oluşturmak için uygulamasının kullanımını DefineGlobalMethod gösterir.

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();
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()

Açıklamalar

Kullanıcı bu dinamik modüldeki tüm genel işlevleri tanımlama işlemi tamamlandığında bu yöntem çağrılmalıdır. Bu işlev çağrıldıktan sonra yeni genel işlevlere veya yeni genel verilere izin verilmez.

Şunlara uygulanır