VS2010:观察变量是不可能的吗?
我使用 VS2010 作为 vb.net 编译器,但有时在调试时无法查看局部变量。
实际上,当我将局部变量添加到监视窗口时,它表示:
'sm' is not declared. It may be inaccessible due to its protection level.
“sm”是我的局部变量,并且已在我的例程中声明。
这是我的一些简单代码片段:
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
嗯,我无法在 sm = Encrypt_Str(c)
行之后观看“sm”。这是什么原因造成的?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对我有用的是进入项目属性,选择“调试”选项卡,然后勾选“启用 Visual Studio 托管进程”框。
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.
如果您使用类似
变量的东西,则不会出现在 Watch 上,因为它只存在于该代码块中。
但这只是猜测。如果你发布一些代码我会更好
if you are using something like
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
我无法查看任何控件/变量..
清理和重建但这也没有帮助,我在配置管理器中创建了一个新配置并复制了我的调试设置,瞧我的手表又像时钟一样工作了;)
问候,
迈克
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
我最近在 Visual Studio 2013 中遇到了完全相同的问题。我正在 ASP.NET 代码隐藏类中调试 VB.NET 代码。我可以断点、单步执行并进入语句,但尝试查看/观察变量会导致该错误:
对我有用的是:
快乐编码。
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:
What worked for me was:
Happy coding.