"'VariableName' is not declared. It may be inaccessible due to its protection level." in Watch window. - by Bkqc

Status : 

  Not Reproducible<br /><br />
		The product team could not reproduce this item with the description and steps provided.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 721851 Comments
Status Closed Workarounds
Type Bug Repros 5
Opened 1/31/2012 8:55:14 AM
Access Restriction Public
Moderator Decision Sent to Engineering Team for consideration


I have a problem VS2010 SP1 VB debugger when trying to watch locally declared variables content. If hover the variable in code, nothing happens (no popup with the value). If I put the wariable in the watch window or try to access it through the immediate window, I get "is not declared. It may be inaccessible due to its protection level", if I use the automatic window, none of my locally defined variables appear.

I tried cleaning and rebuilding, deleting bin content and rebuilding, removing the suo file, cleaning the "Temporary ASP.NET Files" folder, restarting VS, moving back to Fx3.5 and none of of this worked. I'm now stuck with a project I can step through but for which I have no clue what's going inside variables.

Any help will be appreciated!
Sign in to post a comment.
Posted by GeertVW on 8/23/2012 at 2:10 AM
I have the same problem.
Local variables can not be watched.
I use VB 2010 Express.
This does not have the configuration option Tools | Options | Debugging, and under "Enable Just My Code", as described below.
This makes it very hard to use VB Express for programming.
Posted by Bkqc on 6/7/2012 at 8:42 AM
What is suggested here is normal since moving through the stack also moves the context to the selected stack frame. The reported bug is about local variables being not found in current context.
Posted by mayer.axel on 5/30/2012 at 5:35 AM
How to reproduce this failure:

1. Build in VS 2010 a DLL from a complex solution.
2. Run the solution separately.
3. Add a breakpoint to a method with local variables
4. Attach in VS 2010 to the running solution process
5. Use the solution in a way, the the code with the breakpoint is reached.
=> In VS 2010 the code stops.
=> The debugger displays the local variables by hovering over it or in the watch window.

6. Move to the calling method via Call Stack window.
7. Now scroll to the method with the breakpoint. (Scrolling is important. Dont use Call STack or "Show next Statement")
=> Here the local variables are unknown. The Error message is displayed in the Watch window
Posted by Macy [MSFT] on 3/8/2012 at 3:49 AM
Thank you for submitting feedback on Visual Studio 2010 and the .NET Framework. At this point, it has been more than two weeks since we initially requested additional information to reproduce your issue. Since we have not heard back from you we will close the issue. If you need further assistance on this or any other pre-release product issues in the future, please feel free to contact us and we will be happy to help.
Posted by Macy [MSFT] on 2/27/2012 at 11:36 PM

Sorry for bothering. Is there any update?

It would be greatly appreciated if you could provide us with that information as quickly as possible.

Thank you!
Posted by Macy [MSFT] on 2/19/2012 at 11:58 PM
Thanks for your update. Could you please provide us with a demo project to demonstrate this issue?

Thank you again.
Posted by Bkqc on 2/15/2012 at 7:34 AM
I tried what you suggested but as you can see in the latest screenshot, the debugger can't display any variable taht was locally defined but was able to show function arguments correctly. Also, it is not generalized (may be fine in other functions) nor permanent but from what I've seen for now, once it has begun, it can be quite long before it works again.
Posted by Macy [MSFT] on 2/14/2012 at 1:24 AM
Thanks for reporting the issue. Please go to Tools | Options | Debugging, and under "Enable Just My Code", make sure that the option "Show all members for non-user objects in variables windows (Visual Basic only)" is checked.

Could you please let me know if you fix it?

Thank you.
Posted by Macy [MSFT] on 2/8/2012 at 3:35 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by MS-Moderator10 [Feedback Moderator] on 1/31/2012 at 10:33 PM

Could you please provide some screenshots to help us better understand this scenario?

Posted by MS-Moderator01 on 1/31/2012 at 9:44 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)