Why does stack get truncated in Exception.StackTrace?

前端 未结 4 1187
梦如初夏
梦如初夏 2021-02-05 18:31

Why does the high part of the stack (in Exception.StackTrace) gets truncated? Let\'s see a simple example:

public void ExternalMethod()
{
  InternalMethod();
}         


        
4条回答
  •  臣服心动
    2021-02-05 18:58

    This is often caused by the compiler optimizations.

    You can decorate methods you do not want to inline by using the following attribute:

    [MethodImpl(MethodImplOptions.NoInlining)]
    public void ExternalMethod()
    {
      InternalMethod();
    }
    

提交回复
热议问题