Results 1 to 7 of 7

Thread: debug help VS2008

  1. #1

    Thread Starter
    Fanatic Member kevin_sauerwald's Avatar
    Join Date
    Feb 2002
    Location
    outside Philly
    Posts
    516

    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 ?

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member kevin_sauerwald's Avatar
    Join Date
    Feb 2002
    Location
    outside Philly
    Posts
    516

    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

  4. #4
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    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.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

  7. #7

    Thread Starter
    Fanatic Member kevin_sauerwald's Avatar
    Join Date
    Feb 2002
    Location
    outside Philly
    Posts
    516

    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..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width