Results 1 to 8 of 8

Thread: See app while debugging

  1. #1

    Thread Starter
    Lively Member StevenM's Avatar
    Join Date
    Mar 2015
    Posts
    73

    See app while debugging

    Is it possible in VB.Net VS 2010 Ultimate to watch the changes to the application happen while stepping thru the code? This visual aid is a powerful debugging tool under some circumstances.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,947

    Re: See app while debugging

    Of course you can... why wouldn't you be able to?

    -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
    Lively Member StevenM's Avatar
    Join Date
    Mar 2015
    Posts
    73

    Re: See app while debugging

    I can not see the form that contains the code that I am debugging. All I see is the code. I searched the settings in VB 2010 and Google and did not find a way.

    The code is making a change to a dataGridView row and it is a weird one. If I could see the grid while debugging I could identify the line of buggy code.

    The closes I can get to watching the code make changes while stepping thru it is in the form1.vb [Design] view. However, that just displays a static design view of the form, not a current view as changes are taking place.

    If there is a way to see this can you share it?

  4. #4

    Thread Starter
    Lively Member StevenM's Avatar
    Join Date
    Mar 2015
    Posts
    73

    Re: See app while debugging

    From what I found using a Google search the equivalent of watching the form build in VB6 during debugging is not available in VS 2010. Am leaving this thread open just in case someone knows more about this debugging tool.

    Thanks for looking!

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,947

    Re: See app while debugging

    Sigh... right, the design of the form isn't changing... the runtime instance is... so if you want to see the changes being made to the form... you need to put your form and VS side by side.... you're not going to see changes to the form inside the IDE, because that's not what is changing... what is is the app itself...

    or maybe I still don't get it.

    -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
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    11,044

    Re: See app while debugging

    The Design View is not really available at runtime, you cannot change it at such instance, and it was not also possible in VB6.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  7. #7
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,110

    Re: See app while debugging

    They are not talking about design view.
    With VB6 if you stop in the debugger, you can move the form around, or drag other windows across it, and it will remain viewable, as it will continue to refresh itself.
    If you step through the code and the code updates a label, or textbox, or other control, you will see the label, textbox or control update.

    In VB.Net, if you are stepping through the code and drag a window across the form, the form won't refresh.
    If you change the content of a control, you won't see the update immediately as you would in VB6.
    You won't see a change while stepping in the debugger until you step through the paint event, and you won't step through the paint event until you finish stepping through the sub that is updating the control.

    That is what the OP is talking about. Being able to observe the grid being updated as you step through the code updating the grid.

  8. #8
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,110

    Re: See app while debugging

    I don't know how complex your code is and whether it is worth the effort, but the only way I can think to step through code and see the result would be to use a background thread to process the code, with it invoking back to the GUI Thread to update the control.

    Having to move the code you want to debug into a background thread and wrap every line that updates the control with an invocation might be more work than it is worth, but an example of a quick test I did updating a textbox and being able to step through the code and observe the updates follows.

    I create a background thread, which has a continuous loop. (You may also be able to copy the code and make the modifications to invoke, and put it in the DoWork method of a background worker, so you could kick it off in code from a "debug" button perhaps).
    I'm assuming these would only be temporary measures to debug a particularly thorny issue where seeing the fields visually is worth the effort, as opposed to adding a watch on the object and examining the data through the object's properties hierarchy in the watch window.

    In the quick test, I just set up a background thread rather than a Background Worker, as I do that more often in my work, so it quite familiar.
    To prevent the code from executing until I'm ready to step through it, I used a boolean.
    I started the program.
    When I'm ready to step through the code, I set a breakpoint on the If condition line with the boolean, by clicking on the gutter on the left of the window in the IDE. I get the break, I type a command in the immediate window to set the boolean to true (can be done though a watch or quick watch, but I regularly use the immediate window to examine the value of things using the "?" command, e.g. "? Textbox.Length)".
    Of course, if you're stopped in a background thread, you can't do the example ? command because that would be accessing the Textbox control from the background thread, which is not legal.

    Once the boolean value is set to True, then continue stepping through the code.
    In the test case, I can see the textbox update as each Me.Invoke line is stepped.
    Code:
    Public Class Form1
    
      Private bgThread As New Threading.Thread(AddressOf backgroundTest)
    
      Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        bgThread.IsBackground = True
        bgThread.Start()
      End Sub
    
      Private Sub backgroundTest()
        Dim doit As Boolean
        Dim s As String = "Update 1"
        Do
          If doit Then
            Me.Invoke(Sub() TextBox1.Text = s)
            Me.Invoke(Sub() TextBox1.Text = "Trial by fire")
            Me.Invoke(Sub() TextBox1.AppendText(vbCrLf & "What a pain"))
          End If
          Threading.Thread.Sleep(100)
        Loop
      End Sub
    Last edited by passel; Apr 13th, 2015 at 03:14 AM.

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