Asp.net 代码隐藏属性在设计时无法访问,但在运行时可以正常工作

Asp.net 代码隐藏属性在设计时无法访问,但在运行时可以正常工作,asp.net,vb.net,visual-studio-2015,Asp.net,Vb.net,Visual Studio 2015,我必须对传统的ASP.NET网站进行一些更改。它具有如下属性声明: Public ReadOnly Property Foo As String Get If Not Session("Foo") Is Nothing Then Return Session("Foo").ToString() Else Return "" End If End Get End Property 在设计时

我必须对传统的ASP.NET网站进行一些更改。它具有如下属性声明:

Public ReadOnly Property Foo As String
    Get
        If Not Session("Foo") Is Nothing Then
           Return Session("Foo").ToString()
        Else
           Return ""
        End If
    End Get
End Property
在设计时,查看标记页面上的一些javascript,该属性是不可访问的,尽管它在运行时工作正常。这条皱纹使这个问题与其他类似的问题有点不同

  var f = <%= Foo %>;  
我不明白<代码>MyAssemblyName被提到两次,一次是不可用,一次是可用

新信息结束

我已经检查了页面声明:

MyAssemblyName
匹配程序集名称和根命名空间,如项目属性页面所示

应用程序类型为类库

我已经检查了类声明的保护级别:

Public Class Widgets

End Class
并确保Web表单设计器生成的代码存在:

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region
#区域“Web表单设计器生成的代码”
'Web窗体设计器需要此调用。
私有子初始化组件()
端接头
'注意:Web表单设计器需要以下占位符声明。
'不要删除或移动它。
私有designerPlaceholderDeclaration作为System.Object
私有子页_Init(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理MyBase.Init
'CODEGEN:Web表单设计器需要此方法调用
'不要使用代码编辑器修改它。
初始化组件()
端接头
#末端区域

还有什么需要检查的?

您确定项目正在编译吗?尝试清理和重建。遗留应用程序的框架版本是什么?它是旧网站样式的项目吗?已成功清除并重新生成所有报告1 0失败0已跳过。它现在的目标是4.5。我现在正在检查代码并检查名称空间声明。
#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region