什么是一个全球性的方法?是一个、全球性、方法

由网友(宠她)分享简介:什么是.NET一个全球性的方法?我说的是由ModuleBuilder.DefineGlobalMethod方法。What is a global method in .net? I'm talking about the ones created by the ModuleBuilder.DefineGlobalMe...

什么是.NET一个全球性的方法?我说的是由ModuleBuilder.DefineGlobalMethod方法。

What is a global method in .net? I'm talking about the ones created by the ModuleBuilder.DefineGlobalMethod method.

可这些方法从C#或其他.NET语言叫什么名字?

Can these methods be called from C# or other .net languages?

推荐答案

很难谈论这在所有熟悉的术语,这种能力是不是在所有裸露在C#或VB.NET语言。然而,C ++ / CLI编译器使用它。它显示像程序Ildasm.exe或反思反汇编的方式也是不规范的。

Hard to talk about this at all in familiar terms, this capability is not at all exposed in the C# or VB.NET languages. The C++/CLI compiler uses it however. The way it is shown in disassemblers like Ildasm.exe or Reflector is also not standardized.

也许最好的角反射器,看看,看看在System.Data.dll中装配。模块> 节点 - (在反射器),&LT它是一个未命名的命名空间。你看那里的.cctor是一个模块initiailizer。同一种类的动物作为一个静态类的构造函数,但在模块级。它运行时组件被加载。 C ++ / CLI使用它来初始化C运行时库。

Perhaps the best angle is Reflector, take a look-see at the System.Data.dll assembly. It is in an unnamed namespace ("-" in Reflector), <Module> node. The .cctor you see there is a module initiailizer. Same kind of animal as a static class constructor but at the module level. It runs when the assembly gets loaded. C++/CLI uses it to initialize the C runtime library.

在___ CxxCallUnwindDtor()方法,你会发现有一个全球方法的一个例子。在C ++ / CLI语言并没有给任何办法,使这几样功能公众,他们总是嵌入在内部访问的元数据。并因此不能直接从C#或VB.NET程序中调用。我还没有发挥足够的与ModuleBuilder知道是否可以与被搞砸都超出了C ++ / CLI一样。这是所有的非常的模糊不清,实际上并没有那么有用。

The ___CxxCallUnwindDtor() method you find there is an example of a "global method". The C++/CLI language doesn't give any way to make these kind of functions public, they are always embedded in the metadata with internal accessibility. And can thus not be called directly from a C# or VB.NET program. I haven't played enough with ModuleBuilder to know if that can be messed with at all beyond what C++/CLI does. This is all very obscure and not actually that useful.