Reputation: 26547
I use VS2010 as my vb.net compiler but sometimes I cannot watch a local variable while debugging.
Actually, when I add my local variable to watch window, it says that :
'sm' is not declared. It may be inaccessible due to its protection level.
'sm' is my local variable and has beed declared within my routine.
Here is some my simple code snippet:
Public Sub Calculate()
Dim sm As String
Dim c(2) As Byte
c(0) = 49
c(1) = 85
c(2) = 121
sm = Encrypt_Str(c)
'...
'...
End Sub
Well, I cannot watch 'sm' after the line sm = Encrypt_Str(c)
. What causes this?
Upvotes: 2
Views: 2300
Reputation: 1768
I recently had exactly the same issue in Visual Studio 2013. I was debugging VB.NET code in an ASP.NET code behind class. I could break point, step over and into statements, but trying to view / watch a variable would result in that error:
'myvar' is not declared. It may be inaccessible due to its protection level.
What worked for me was:
Happy coding.
Upvotes: 0
Reputation: 11
What worked for me was going into the project properties, selecting the 'Debug' tab and then ticking the 'Enable the Visual Studio hosting process' box.
Upvotes: 1
Reputation: 687
I couldn't watch any of my controls / variables.. Cleaned and rebuilded but that didn't help either, I created a new configuration in the configuration manager and copied my debug settings et voila my watch worked like a clock again ;)
Regards,
Mike
Upvotes: 0
Reputation: 1421
if you are using something like
For Dim i as Intenger To something
//Do something
Next i
something() //You are debuging here
The variable wount appear on Watch since it just exists for that block of code. But is only a guess. I could be better if you post some code
Upvotes: 0