【问题标题】:Unrecognized Tag Prefix or Device Filter in Visual Studio 2008Visual Studio 2008 中无法识别的标记前缀或设备筛选器
【发布时间】:2009-09-04 10:14:23
【问题描述】:

我有一组 Web 控件,它们位于网站引用的程序集中。我可以毫无问题地构建和运行所有内容,但是当我查看正在使用控件的 aspx 页面时,我会在标记前缀下方看到一个绿色下划线。

<%@ Register Assembly="MyProject.UI.ControlLibrary" Namespace="MyProject.UI.ControlLibrary.Web" TagPrefix="ControlLibrary" %>
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" Runat="Server">
    <ControlLibrary:ListView ID="List" runat="server"/>
</asp:Content>

所以在这个例子中,我会在 ControlLibrary 下得到一个绿色下划线,当我将鼠标悬停在它上面时,它会显示 Unrecognized Tag Prefix or Device Filter 'ControlLibrary'

代码是在以前版本的 Visual Studio 中编写的,我还有另一个程序集也包含 Web 控件,并且似乎工作正常。

关于什么可能导致问题的任何想法?

【问题讨论】:

    标签: c# visual-studio-2008 asp.net


    【解决方案1】:

    尝试将引用更改为web.config,如果有任何结果,看看会出现什么错误?以下是位置引用的根 &lt;asp: 标记添加示例。我喜欢这种方法,因为如果您经常使用该库,它也会使页面保持清洁。看看移动库引用后是否得到相同的结果。

    <system.web>
      <pages>
        <controls>
          <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    

    更新 - 根据您的评论,尝试删除

    中的所有内容

    Drive:\Documents and Settings\[User]\ApplicationData\Microsoft\VisualStudio\9.0\ReflectedSchemas

    或短版:

    %APPDATA%\Microsoft\VisualStudio\9.0\ReflectedSchemas\

    【讨论】:

    • 是的,我也是它的忠实拥护者,上次我在研究这个问题时切换了,所以这实际上是我目前的做法。没有区别。
    • 删除 ReflectedSchemas 对我有用,所以感谢您的回答。
    【解决方案2】:

    &lt;%@ Import %&gt; 指令放在&lt;%@ Register %&gt; 指令上方:

    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
    
    <%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    

    【讨论】:

    • 优秀。 Intellisense 的 VS2012 SharePoint 2010 应用程序页面问题正是我所需要的。
    【解决方案3】:

    很难说是什么原因,但是Visual Studio中的ASP.NET XML解析器经常会出现这样的问题。以下是我发现的一些可能的解决方法,也许其中一些也适用于您:

    • 打开 .aspx 文件后,稍等片刻。 VS 需要一点时间来解析文件并设置它的 IntelliSense;
    • 尝试在 .aspx 文件打开并显示在屏幕上时编译项目。成功的构建通常可以解决这些问题。如果这不起作用,请尝试重建项目甚至整个解决方案。再一次 - 稍等一下。
    • 如果一切都失败了,将标签前缀定义放在 web.config 文件中:

      <configuration><system.web><pages><controls>
          <add tagPrefix="ControlLibrary" namespace="MyProject.UI.ControlLibrary.Web" assembly="MyProject.UI.ControlLibrary"/>
      </controls></pages></system.web></configuration>
      

      当然,尝试重建等。

    【讨论】:

    • 好建议,这些已经解决了我遇到的其他问题,但不是这个。
    【解决方案4】:

    不知道为什么会这样,但确实如此。当我将其中一个 listview 控件的命名空间从 MyProject.UI.ControlLibrary.Web 更改为 MyProject.UI.ControlLibrary 并重新指向

    【讨论】:

      【解决方案5】:

      在我的例子中,我发现如果控件程序集已经注册到 web.config 中的前缀,然后您尝试使用 @register 将它注册到不同的前缀,那么您将收到此错误消息。

      【讨论】:

      • 这是 -1 的结果,因为答案恰好与问题的确切分辨率不匹配?如果您尝试这种情况,它确实会重复问题中提到的条件。我可以查看我的回复是否完全偏离了基础,但 -1 表示答案与问题无关、未提供具体信息、不正确或具有其他误导性。否则,您可能只想留下一个答案,因为这可能是其他人遇到问题的原因。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-28
      相关资源
      最近更新 更多