Understanding the Stack Trace

Discussion in 'ASP .Net' started by =?Utf-8?B?SmVyZW15?=, Jan 22, 2004.

  1. While working with ASP.NET I've sometimes encountered errors in my applications, but I've always known exactly why I'm getting the error and have been able to fix it. So I've never needed to understand the Stack Trace, but I want to understand the stack trace so can somebody please explain it to me or point me to something that will

    Thanks
    Jeremy
    =?Utf-8?B?SmVyZW15?=, Jan 22, 2004
    #1
    1. Advertising

  2. Basically, the Stack Trace is a trace of function calls that go on the
    Stack. When a program runs, it copies functions from the Heap to the Stack,
    in a "Stack" (so to speak) which is a stack of the functions. When a
    function is called, a copy of it is put on the Stack to execute. When a
    function exits, it is pulled from the Stack. If it calls other functions,
    these are stacked on top of it, and each one is pulled off the Stack when it
    exits.

    The Stack Trace shows the "topmost" (latest) functions called. It helps
    identify the chain of execution that led up to the current situation
    (usually an exception). It identifies each function on the Stack in the
    order (reversed) in which they appear, with the last one executed at the
    top.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Jeremy" <> wrote in message
    news:...
    > While working with ASP.NET I've sometimes encountered errors in my

    applications, but I've always known exactly why I'm getting the error and
    have been able to fix it. So I've never needed to understand the Stack
    Trace, but I want to understand the stack trace so can somebody please
    explain it to me or point me to something that will?
    >
    > Thanks,
    > Jeremy
    Kevin Spencer, Jan 22, 2004
    #2
    1. Advertising

  3. Kevin has a great technical explanation, so I will go to an analogy.

    First, let's understand why the word Stack is applicable. Let's imagine a
    deck of cards and you are playing solitaire. As you get to cards you cannot
    play, you add them to the discard pile (or stack). Each card is stacked on
    top of another one.

    To equate to programming, Card1 (the first card on the discard pile) calls 2
    which calls 3. You cannot finish working with card 1 until you have played
    card 2 and card 3 (and so on). This would be like function Card1() calling
    function Card2(), which calls function Card3. If you break inside the
    Card3() function, you have a stack like so:

    Card3
    Card2
    Card1

    Now, let's say Card3 returns an answer that Card2 processes, and Card2 has
    an error. The stack now looks like so:

    Card2
    Card1

    In the stack trace, you will see Card2 with a line number and Card1 with a
    line number, if you have the IDE set to break on all errors, or if you let
    the error remain when deployed and do not have a Try ... Catch to handle the
    error.

    Sometimes what you do in your code does not throw an exception until it hits
    the .NET Framework components. In these cases, you often have to look down
    the stack until you hit your own functions to determine what actually caused
    the error.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    **********************************************************************
    Think Outside the Box!
    **********************************************************************
    "Jeremy" <> wrote in message
    news:...
    > While working with ASP.NET I've sometimes encountered errors in my

    applications, but I've always known exactly why I'm getting the error and
    have been able to fix it. So I've never needed to understand the Stack
    Trace, but I want to understand the stack trace so can somebody please
    explain it to me or point me to something that will?
    >
    > Thanks,
    > Jeremy
    Cowboy \(Gregory A. Beamer\), Jan 22, 2004
    #3
  4. =?Utf-8?B?SmVyZW15?=

    sassyboy

    Joined:
    Sep 5, 2009
    Messages:
    1
    I have been developing ASP.NET applications for some time now and always wondered what the Stack Trace meant.. Those explanations were just so great...Thanks

    Reading this thread felt like finding a treasure island... :captain:
    sassyboy, Sep 5, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rukmal Fernando
    Replies:
    4
    Views:
    828
    Richard Grimes [MVP]
    Oct 27, 2003
  2. Matthias S.
    Replies:
    1
    Views:
    619
    Daniel Fisher\(lennybacon\)
    Nov 30, 2005
  3. Jiho Han
    Replies:
    0
    Views:
    488
    Jiho Han
    Aug 22, 2006
  4. =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=

    Adding my messages to the trace.axd trace?

    =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=, Apr 6, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    568
    =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=
    Apr 6, 2007
  5. Chris Newby
    Replies:
    0
    Views:
    753
    Chris Newby
    Jul 28, 2008
Loading...

Share This Page