这种行为在vb.net Web应用程序解决方案中,该应用程序具有由Web应用程序引用的多个类库项目.
原文链接:/vb/255616.html代码编译,但在调试模式下,引用的类库中的一些函数/子例程具有显示的局部变量
‘var_name’ is not declared. It may be inaccessible due to its
protection level.
在手表和即时窗口.
mouse_over智能感知在这些局部变量上不起作用.
在某些子/函数中,变量的值可以访问,直到我进入Try..Catch
传入子/功能的所有变量均可访问.在类级别定义的变量也可以访问.
这个行为是多年来在解决方案中的代码中的新特性.子程序和功能的范围没有变化(它们是公共的).
它也不一致.在给定的类库项目中,一个类中的公共函数/子例程将具有可以看到它们的值的局部变量,而其他类显示上面显示的消息.
我已经尝试过的事情
* Clean/Rebuild Solution * Turn off Code optimizations (it has always been turned off in Debug mode) * Enable the "Show all members for non-user objects in variables windows (Visual Studio)" option in the Debugging options. * Import default settings for VS2012 * Update VS2012 to latest version (Update 4) * Install VS2013 and open solution (behavior occurs there as well) * Clear AppData cache * In Advanced Compiler Settings,set 'Generate debug info' to both Full and pdb-only * Remove local copy of solution and get the solution again from TFS * All projects in the solution are set to Debug
我有一个同事在TFS中获得相同的解决方案的副本,并且行为不会发生在他的本地副本中.
VS2010中没有出现这种情况.
下面是一个方法和本地变量声明的示例,发生此行为.
如果您遍历声明并设置监视任何本地变量或使用局部变量的任何语句,您将看到
‘var_name’ is not declared. It may be inaccessible due to its
protection level.
作为手表/快速手表/即时窗口中变量的值
Utility1.vb
Imports System.Web Imports System.Text Imports SPBO Public Class Utility1 Public oNav_inc As New Navigation_INC '=========================================================================== 'Utility1.vb '=========================================================================== Public Sub UTIL_EstablishActivityContext(ByRef Response As HttpResponse,ByRef page As Page,ByRef oGlobal_inc As GlobalVariables_INC) Dim oActivity As ENC2.Web.ActivityContext Dim oMHardUBO As MHUBO Dim oPUBO As PUBO Dim asGroup As String = "" Dim sGroup As String = "" Dim bActive As Boolean Dim g_oUserAccountBO As UserAccountBO Dim sImplementation As String = "" Dim rs As DataSet Dim sQuery As String Dim rsUser As DataSet Dim sUserGroups As Object Dim iLoop As Integer Dim bInternal As Boolean Dim g_bInternalUser As Boolean g_bInternalUser = False 'rest of code End Sub End Class
更新:我进行了重新格式化/重新映像笔记本电脑并安装了VS2013.问题不再出现.