-
debug help VS2008
ok I get an error that I trap.. but I need to know all the previous calls that
happened before it hit.. that data I can get from the stackframe ?
really I just want to get a list of each proc or function that was called up untill the program failed or just hit this trap..
any easy way to do this in VS 2008 ?
I used Martin's trace at the top of each function and proc in VB6.. but was hoping there would be a nice way in VS2008 that it could be done ?
-
Re: debug help VS2008
You can get to it as text... but not necessarily as a list that you can iterate through... look at the exception object... StackTrace is the property you are interested in:
http://msdn.microsoft.com/en-us/libr...n_members.aspx
-tg
-
Re: debug help VS2008
I was tryin to use this.. which kinda looks like it may use the same class ??
but it gives me way down deep call names.. I just want the title of the sub proc.. thats it..
Code:
Private Sub PrintStack()
' Create a StackTrace that captures
' filename, line number, and column
' information for the current thread.
Dim st As New StackTrace(True)
Dim i As Integer
Dim TextOut As String
For i = 0 To st.FrameCount - 1
' Note that high up the call stack, there is only
' one stack frame.
Dim sf As StackFrame = st.GetFrame(i)
Console.WriteLine()
TextOut = "High up the call stack, Method: " & sf.GetMethod().ToString & vbCrLf
TextOut = TextOut + "High up the call stack, Line Number: " & sf.GetFileLineNumber().ToString & vbCrLf & vbCrLf
My.Computer.FileSystem.WriteAllText("C://testfile.txt", TextOut, True)
Next i
End Sub
-
Re: debug help VS2008
I think you misunderstood.
Whenever an exception is thrown, Visual Studio shows you the exception window, right? The pop-up 'window' (which is not really a window but drawn onto the editor) shows some information relevant to the error. There is also a Details button or link, and there you can view the StackTrace. You don't have to do anything special to see it (let alone write code for it), you just have to find it.
-
Re: debug help VS2008
Nick - true, but you only get that during debugging... what about tracking exceptions at run-time? knowing where the error ocurred can be a valuable thing.
kevin - you'll need to check the stackTrace object there.... it's going to have the whole stack, from the top to the bottom... you'll need to sort through it somehow and figure out which end of the stack it is that you are interested in...
-tg
-
Re: debug help VS2008
If you call a ToString on the exception object you get the StackTrace (amongst other things) right? So maybe you can use that?
-
Re: debug help VS2008
I check into that.. but really I just want a way to know at any point
when the program is running that I can see what procs were called up
to that point..
for my error is a on goto error.. not an exception.. so I'm not throwing one..
so to put it real simple..
if I have a program that has one button and when you click it it tries to
get me what procs were call so far I would expect to get
form_load
btnGetProcCalls
then if I hit it again..
form_load
btnGetProcCalls
btnGetProcCalls
to be honest I'm just trying to figure out what a client is doing since I cannot reproduce his error..
I have code that parses some XML and I have an error trap in there to spit out some xml parse error.. and at the end of it I have on error goto 0 to stop it.. but seems like something is still making it hit that error trap.. so I'm just trying to get a list of the last procs that were run when it hits that error trap in error to see what the deal is..