A stack frame is the way that .NET keeps track of what sub/function/method/whatever you want to call it you are in, which one called that, which one called that one etc. all the way up to the main function that runs the whole program. It also keeps track of where it is up to within each function.
For example, if you have the following code (in VB.NET as usual): -
1 Module Module1 2 3 Sub Sub3() 4 5 End Sub 6 7 Sub Sub2() 8 Sub3() 9 End Sub 10 11 Sub Sub1() 12 Sub2() 13 End Sub 14 15 Sub Main() 16 Sub1() 17 End Sub 18 19 End Module
If we were to stop at Line 4, the stack frame would look something like this…
Sub3:4
Sub2:8
Sub1:12
Main:16
Of course it is a bit more complicated than this, but that is the gist of it. The same idea applies for most other languages.
- The .NET Stack Part 1: How The Stack Works
- The .NET Stack Part 2: The StackTrace Class
No related posts.
Tags: .NET, .NET Framework, Coding












[...] Wizz’s Coding Solutions Problems that I come across in day to day coding « The .NET Stack Part 1: How The Stack Works [...]
[...] This returns a string that contains a stack trace that you can use to see how the code got to this point. It can be very useful for [...]