locked
Public variables not in scope of debug RRS feed

  • Question

  • I am using VB.net in VS 2005 installed on a Windows 7, 64 bit PC. It has all the updates.

    Works fine except for one problem. The debugger (by hover or quickwatch) can only see variables in the same document. Any variables defined elsewhere, even though they are declared as Public, are shown as not defined, although the correct values are being used in the code.

    The only way I can check a value in debug is to assign to a temporary local variable and check that.

    Grateful for any ides on this one.
    Tuesday, February 9, 2010 5:13 PM

Answers

  • Ah! Did that and it worked normally without using Object ID. The globals were all defined in a module with no executable code (It's a conversion from VB6) but just putting in a sub, even though I am not calling it, sorted the problem. I just need to relocate my public vars. Thanks.
    • Marked as answer by liurong luo Wednesday, February 17, 2010 2:53 AM
    Tuesday, February 16, 2010 12:49 PM

All replies

  • Hello,

    We could make an ObjectID of our variables in managed code (VB.NET, C#).

    Please take a look at thest samples for the detail:
    http://blogs.msdn.com/jimgries/archive/2005/11/16/493431.aspx
    http://blogs.msdn.com/dancre/archive/2006/02/10/managed-code-debugging-tip-make-object-id.aspx

    Best regards
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    Wednesday, February 10, 2010 4:46 AM
  • Thanks very much for the reply but unfortunately nothing appears on hovering over the variable. Right click gives options to find definition and find all references but that's it.

    I suspect there is some flag set in all that XML stuff VS sets up but no idea where. Tried changing various debug options on project page.
    Wednesday, February 10, 2010 5:15 PM
  • Hello,

    Please right click the variable name on datatip (a pop up with a glass icon).

    An alternative way is to add the variable in Watch window and right click the variable name.

    Also, this feature is avaiable for reference type variables, not value type variables.

    Please have a try and let me know the result,
    Best regards
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    Thursday, February 11, 2010 9:47 AM
  • Thanks but I am not getting any data tips on any variables except those defined in the document. All other variables are shown in the watch window as being out of scope.

    PS Sorry not to reply earlier but had the live maily thing turned off.
    Monday, February 15, 2010 9:37 PM
  • You need to debug into the code where you defined the variables firstly to make it an Object ID and then view its value some where else.

    Best regards


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    Tuesday, February 16, 2010 3:38 AM
  • Ah! Did that and it worked normally without using Object ID. The globals were all defined in a module with no executable code (It's a conversion from VB6) but just putting in a sub, even though I am not calling it, sorted the problem. I just need to relocate my public vars. Thanks.
    • Marked as answer by liurong luo Wednesday, February 17, 2010 2:53 AM
    Tuesday, February 16, 2010 12:49 PM
  • Hmmm - I have the same symptoms but that didn't work for me.

    I have a Visual Studio 2005 project that works fine on multiple Windows 7-32 bit PC's.   I just got a new laptop that came with Windows7-64 bit (unfortunately).  I loaded Visual Studio 2005, and applied all the recommended service packs.  My project compiles and runs fine but if I stop at any breakpoint, the only variables that are visible to the debugger are only those that are local to the current module.  Any variables in other modules will come up as undefined if you add them to the Watch list.  If you mouse over them nothing pops up.

    I already have subs in the module with these "invisible" variables.   If I put a breakpoint in one of those subs then that modules variables are visible but no others are.  If I then continue to a breakpoint in another module, only that module's vars are visible.

    Any ideas?  Help!
    Wednesday, March 3, 2010 6:46 PM
  • I am having this exact same issue. Is there any sort of resolution for this?  I have Windows 7/64 bit, Visual Studio 2008.  Only the variables defined in the local document are evaluated in the debugger for the watch/local/immediate windows and the datatips.

    I should note that before I upgraded my machine from Windows XP to Windows 7, it worked fine in my Visual Studio 2008 with the same code solutions.


    Friday, March 5, 2010 8:32 PM

  • I had the same problem!! I have Windows 7 (64 bits) and Visual Studio 2005.

    I managed to access to debug variables in this way:
     
                In code:  MyVariable --> It's not declared

                In debug watching:    MyApplication.MyModule.MyVariable --> Debug Value


    Sorry for my english!!
    Monday, March 8, 2010 4:30 PM