What is the global method?

What is the global method in .net? I am talking about those created by the ModuleBuilder.DefineGlobalMethod method.

Is it possible to call these methods from C # or other .net languages?

+8
source share
2 answers

It is difficult to talk about this in general in familiar terms; this feature is not revealed at all in C # or VB.NET. However, the C ++ / CLI compiler uses it. The way it is shown in disassemblers such as Ildasm.exe or Reflector is also not standardized.

Perhaps the best angle is Reflector, see the System.Data.dll assembly. It is located in the unnamed namespace ("-" in Reflector), the <Module> node. You see .cctor is a module initializer. The same animal as the constructor of the static class, but at the module level. It starts when the assembly loads. C ++ / CLI uses it to initialize the C runtime library.

The ___ CxxCallUnwindDtor () method you will find is an example of a "global method". The C ++ / CLI language does not make it possible to make these functions publicly available; they are always embedded in metadata with internal accessibility. And thus, it cannot be called directly from a C # or VB.NET program. I have not played enough with ModuleBuilder to know if there is anything to be confused, other than what C ++ / CLI does. This is all very obscure and not very useful.

+4
source share

A global method means that a method can be called without fully defining its name, i.e.

Method (Parameter) instead of module. Method (Parameter).

In vb, the public method inside the module is global.

In C #, the public static method in a static class is global.

0
source share

All Articles