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.
Hans passant
source share