VS2010:观察变量是不可能的吗?

发布于 2024-11-29 14:40:19 字数 498 浏览 1 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

谎言 2024-12-06 14:40:19

对我有用的是进入项目属性,选择“调试”选项卡,然后勾选“启用 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.

森林很绿却致人迷途 2024-12-06 14:40:19

如果您使用类似

For Dim i as Intenger To something
  //Do something
Next i

something() //You are debuging here

变量的东西,则不会出现在 Watch 上,因为它只存在于该代码块中。
但这只是猜测。如果你发布一些代码我会更好

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

黑寡妇 2024-12-06 14:40:19

我无法查看任何控件/变量..
清理和重建但这也没有帮助,我在配置管理器中创建了一个新配置并复制了我的调试设置,瞧我的手表又像时钟一样工作了;)

问候,

迈克

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

甜扑 2024-12-06 14:40:19

我最近在 Visual Studio 2013 中遇到了完全相同的问题。我正在 ASP.NET 代码隐藏类中调试 VB.NET 代码。我可以断点、单步执行并进入语句,但尝试查看/观察变量会导致该错误:

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

对我有用的是:

  1. 清理整个解决方案 - 因此,右键单击解决方案资源管理器中的解决方案窗口,然后选择“清洁解决方案”。
  2. 重建解决方案。
  3. 在调试模式下运行 - 现在可以查看/监视变量。

快乐编码。

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:

  1. Do a clean of the entire solution - so, right click on the solution in the solution explorer window then select Clean Solution.
  2. Rebuild the solution.
  3. Run in debug mode - variable can now be viewed / watched.

Happy coding.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文