如何使用反射器来查看.NET库函数的实现

时间:2021-09-02 06:41:56

I tried to see the implementation of [MethodImpl(MethodImplOptions.InternalCall)] public extern int get_Length(); function, which in turn is Length property of string.

我试图看到[MethodImpl(MethodImplOptions.InternalCall)] public extern int get_Length();的实现。 function,又是string的Length属性。

But reflector gave me the following error:

但是反射器给了我以下错误:

The member is not loaded or may be hidden due to your visibility settings

由于您的可见性设置,该成员未加载或可能被隐藏

However the member is loaded and the visibility settings is ALL

但是会加载成员并且可见性设置为ALL

2 个解决方案

#1


I belive the extern methods are the ones that are "typically" implemented using other DLLs, mostly native ones. And of course, when that is the case you are out of the reflection turf!

我相信extern方法是那些“通常”使用其他DLL实现的方法,主要是本机方法。当然,在这种情况下,你已经不在反思的地盘了!

#2


Certain very important types like String have many methods that are implemented using native code. The Length property of String is one such example. This can also be seen from the extern modifier. Reflector cannot show you the implementation of these methods.

某些非常重要的类型(如String)有许多使用本机代码实现的方法。 String的Length属性就是这样一个例子。这也可以从extern修饰符中看出。 Reflector无法向您展示这些方法的实现。

#1


I belive the extern methods are the ones that are "typically" implemented using other DLLs, mostly native ones. And of course, when that is the case you are out of the reflection turf!

我相信extern方法是那些“通常”使用其他DLL实现的方法,主要是本机方法。当然,在这种情况下,你已经不在反思的地盘了!

#2


Certain very important types like String have many methods that are implemented using native code. The Length property of String is one such example. This can also be seen from the extern modifier. Reflector cannot show you the implementation of these methods.

某些非常重要的类型(如String)有许多使用本机代码实现的方法。 String的Length属性就是这样一个例子。这也可以从extern修饰符中看出。 Reflector无法向您展示这些方法的实现。