tags:

views:

133

answers:

1

I'm tracking down a NullReferenceException and the official documentation is lacking.

This is C# 2.0 code.

+2  A: 

Looking at Reflector, it looks like it can:

[MethodImpl(MethodImplOptions.NoInlining)]
public static MethodBase GetCurrentMethod()
{
    StackCrawlMark lookForMyCaller = StackCrawlMark.LookForMyCaller;
    return RuntimeMethodInfo.InternalGetCurrentMethod(ref lookForMyCaller);
}

and InternalGetCurrentMethod looks like:

internal static MethodBase InternalGetCurrentMethod(ref StackCrawlMark stackMark)
{
    RuntimeMethodHandle currentMethod = RuntimeMethodHandle.GetCurrentMethod(ref stackMark);
    if (currentMethod.IsNullHandle())
    {
        return null;
    }
    return RuntimeType.GetMethodBase(currentMethod.GetTypicalMethodDefinition());
}
John Rasch
Thanks! I should probably get around to installing Reflector.
emptyset