Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging with Visual Studio 2010 and VB.NET: Immediate fails due to protection level

It happens quite frequently, more times per day, that with Visual Studio 2010, during the debugging, when I used Immediate commands like:

? NamedVariable

I receive the following error:

'NamedVariable' is not declared. It may be inaccessible due to its protection level.

In this case also other debug features seems gone, but I can set breakpoints, step into, step over, etc.

The solution is stop debugging, clean and rebuild the project, and retry.

I am developing a VB.NET Windows Forms application, but it happened with VB.NET WPF projects too. I never had this behavior with VS 2008.

Is this a known bug or could it be a problem of my environment/installation? Do you have any idea how to solve this little, but annoying issue?

like image 833
Drake Avatar asked Jun 15 '10 09:06

Drake


People also ask

How to debug a program in Visual Studio?

From the Debug Menu, you can select "Start Debugging" or just press F5 to start the program. If you have placed breakpoints in your code, then execution will begin automatically. There is another way to start the debugging by "Attach Process". Attach process will start a debug session for the application.

What are the new features of Visual Studio 2010 debugging?

This is another great feature of Visual Studio 2010 debugging. If you pinned some data tip during the debugging, the value of pinned item will remain stored in a session. In normal mode of coding, if you mouse over the pin icon, it will show the details of the last debugging session value as shown in the the below picture:

What are debug classes in the NET Framework?

Among the many diagnostic classes the .NET Framework provides are the Debug classes. The Debug class helps us debug code, the Debug class is intended for debug builds. Table 21.3 describe the members of the Debug classes. You must define the DEBUG compiler directives to activate debugging respectively.

What is the difference between fail () and flush () methods of the debug classes?

The Fail () method of the Debug classes produces an error message so you can handle exceptions and errors during debugging more easily. The Flush () method of the Debug classes forces buffered data to pour to the Listeners collection immediately. We will talk about listeners later.


1 Answers

This happens quite often to me, too. And the only solution I found out up to now is:

The solution is stop debugging, clean and rebuild the project, and retry.

Deleting the suo file will not help. And it can happen anywhere in the code and does not seem to be depending on the code itself.

I think this is happening mostly after I modified some code during debugging or after a lot of minor changes and builds before the debugging. Maybe the debugging information gets "lost" or "unsynrconised" during some partial build process.

I think its a VisualStudio bug and that it will be fixed in a hopefully soon ServicePack.

like image 128
WizzardsApprentice Avatar answered Oct 04 '22 12:10

WizzardsApprentice