473,769 Members | 3,084 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Understanding the Stack Trace

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
Nov 18 '05 #1
3 24523
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" <an*******@disc ussions.microso ft.com> wrote in message
news:7A******** *************** ***********@mic rosoft.com...
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

Nov 18 '05 #2
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" <an*******@disc ussions.microso ft.com> wrote in message
news:7A******** *************** ***********@mic rosoft.com...
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

Nov 18 '05 #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" <an*******@disc ussions.microso ft.com> wrote in message
news:7A******** *************** ***********@mic rosoft.com...
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

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2515
by: Andy Fish | last post by:
Hi, in my c# code I have something like this: try { ... } catch (Exception ex) { ... throw ex; }
3
5458
by: Mike Schilling | last post by:
Instances of SystemOutOfMemoryException do not contain a stack trace. Easy test to verify this: class OOM { public static void Main() { try { Object arr = new Object; } catch (Exception ex) { dumpEx(ex);
0
3677
by: Mike Schilling | last post by:
I have some code that calls methods reflectively (the method called and its parameters are determined by text received in a SOAP message, and I construct a map from strings to MethodInfos). The code that does the call looks roughly like: try { // do reflective call response = method.Invoke(obj, params); }
2
4390
by: Lasse Vågsæther Karlsen | last post by:
If I got the following code: try { // something that might throw an exception } catch (Exception ex) { // Log contents of ex here throw;
3
3720
by: barker7 | last post by:
I am calling an unmanaged C++ method from C#. When an exception occurs in the C++ code, it gets caught in our C# code. CSharpMethod() { try { NativeCPPMethod(); } catch (Exception e)
5
1951
by: Mr. SweatyFinger | last post by:
WHY CAN'T THE CLOWN -HOLES WHO WROTE ASP.NET PROVIDE AN ERROR LINE NUMBER??? HONEST TO SH@THOLE PETE Server Error in '/New Folder (7)' Application. -------------------------------------------------------------------------------- The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. Description: An unhandled exception occurred during the execution of the current web request....
2
3480
by: pavel.orehov | last post by:
Hi, I am using Environment.StackTrace to print the stack trace to the log when I have any exceptions in my application. When I work in development environment I see the line numbers in the trace without any problems. However when an application runs at the production PC deployed with VS2005 setup I don't see line numbers in the stack trace.
3
7228
by: Dave Anson | last post by:
I have a custom exception and I want to write the information to the event log, including the Stack Trace. I can create the message and write to the event log no problem, but the Stack Trace is empty. How do I append the Stack Trace in the custom exception? I can get the inner exception stack trace from the system exceptions, but how do I get my own stack trace information. Thanks in advance
3
7726
by: Sendil kumar | last post by:
Hi All, Problem Stetement:I have a problem in getting stack trace when I ues std::exception. In my code, I allocate virtual memory for certain kind of processing and will throw the std::bad_alloc exception if memory could not be allocated. I have never handled the bad_alloc, so, what I expect here is a stack trace from windows showing the excact location where the exception was thrown. But, to my surprise it gives only the windows ...
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.