none
Exception call stack question RRS feed

  • Question

  • I am working on testing an application.  When a test fails, I am dumping the call stack to a file.  After reviewing several call stacks, I noticed one with a form that I am not familiar with.  In the call stack, each function explicitly calls the next from bottom to top.  My question is this, the final method reported on the call stack is never explictly called from the caller.  Everything else reported on the stack follows expected behaviour.  Can anyone explain this?

    Example of abbreviated call stack:

    Message: Object reference not set to an instance of an object.
    Stacktrace:    at SomethingElse.WhoKnows(Object o)
    at SomeClass.MethodTwo()
    at SomeClass.MethodOne()
    at SomeClass.MethodOrigin()

    Therefore, my problem is this, the WhoKnows() method is never explicitly called from MethodTwo().

    Thursday, August 21, 2008 5:30 PM

Answers

  • So, here is the answer.  The MethodTwo() method gets a property that in turn calls WhoKnows(Object o).  The getter does not get reported on the call stack.  It is likely inlined during compilation.  This is something that I was not aware of in the past.

    Thursday, August 21, 2008 8:49 PM

All replies

  • So, here is the answer.  The MethodTwo() method gets a property that in turn calls WhoKnows(Object o).  The getter does not get reported on the call stack.  It is likely inlined during compilation.  This is something that I was not aware of in the past.

    Thursday, August 21, 2008 8:49 PM
  • Yes.  You can apply this attribute to suppress inlining, if really necessary:

        [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]


    Hans Passant.
    Friday, August 22, 2008 12:52 AM
    Moderator