开发者

Why doesn't Visual Studio allow me to step into Type.GetType()?

开发者 https://www.devze.com 2023-03-21 23:23 出处:网络
I\'ve got the following simple code: class Program { static void Main(string[] args) { var t = Type.GetType(\"System.Reflection.Assembly\");

I've got the following simple code:

class Program
{
    static void Main(string[] args)
    {
        var t = Type.GetType("System.Reflection.Assembly");

        Consol开发者_高级运维e.WriteLine(t.FullName);
    }
}

I'm attempting to debug into the Type.GetType() method, but the debugger skips over the method even when using "Step Into". I've got debugging enabled for the .NET Framework classes, and debugging into other framework methods works fine. Why doesn't the debugger allow me to step into this particular method?


Because Type.GetType() is inlined to this:

[MethodImpl(MethodImplOptions.InternalCall), SecuritySafeCritical]
public extern Type GetType();

In other words, the method is implemented in C++ inside the CLR. The InternalCall attribute value is the key. Source code for the CLR is not available from the Reference Source. You could use the SSCLI20 source code for reference, it is a pretty good match for CLR source but you can't trust it to be completely accurate, it is no longer maintained. The clr/src/vm/ecall.cpp source code file contains the mappings from InternalCall names to C++ function names.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号