【问题标题】:Parsing error after editing Asp.Net User Control markup编辑 Asp.Net 用户控件标记后解析错误
【发布时间】:2014-05-30 21:34:51
【问题描述】:

我有一个 asp.net webforms(.Net 4.0,Visual Studio 2013)用户控件,现在可以完美运行。它使用 asp 标签控件和资源标签来根据当前用户的语言/文化设置引入文本。

我需要添加一些文字。

但是,添加新的 asp 标签会自动产生解析错误。一旦出现错误,我不能只删除标签。我必须将我的标记和设计器代码恢复到我上次提交的状态。在我看来,设计器代码中一定有一些东西被破坏了,但我不知道从哪里开始寻找。

下面是解析错误:

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'OnlineRegistration.Confirmation'.

Source Error:


Line 1:  
Line 2:  <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Confirmation.ascx.vb" Inherits="OnlineRegistration.Confirmation" %>
Line 3:     
Line 4:      <asp:Label 


Source File: /WebPages/ConfirmationUCTL/Confirmation.ascx    Line: 2 

这是用户控件的标记

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Confirmation.ascx.vb" Inherits="OnlineRegistration.Confirmation" %>

    <asp:Label 
        ID="litConfirmation" 
        runat="server" 
        meta:resourcekey="litConfirmationResource1"/>

    <p>
        <asp:Label 
            ID="litConfirmationThankYou" 
            runat="server" 
            meta:resourcekey="litConfirmationThankYouResource1"/>

           <strong>&nbsp
            <asp:Label 
                ID="litConfirmationNumber" 
                runat="server" 
                meta:resourcekey="litConfirmationNumberResource1"/>
        </strong>.&nbsp

          <asp:Label 
            ID="litConfirmationProcessing" 
            runat="server" 
            meta:resourcekey="litConfirmationProcessingResource1"/>
    </p>
<asp:Label ID="Label1" runat="server" Text="Label" />                  
    <p>
        <asp:Label 
            ID="litConfirmationVNC" 
            runat="server" 
            meta:resourcekey="litConfirmationVNCResource1"/>
    </p>               

    <p>
        <asp:Label 
            ID="litConfirmationQuestions" 
            runat="server" 
            meta:resourcekey="litConfirmationQuestionsResource1"/>
    </p>

    <p>
        <asp:Label 
            ID="litErrorSaving" 
            runat="server" 
            meta:resourcekey="litErrorSavingResource1" 
            CssClass="hide"/>
    </p>

    <asp:HyperLink 
            ID="linkPrintVRA" 
            runat="server" 
            meta:resourcekey="linkPrintVRAResource1" 
            CssClass="hide"/>

我所做的就是添加这个:

<asp:Label ID="Label1" runat="server" Text="Label" />     

然后编译运行。并出现解析错误。

知道从哪里开始寻找这个错误吗?

【问题讨论】:

  • 感谢您的链接。但这是在我的开发箱上,我已经检查了所有参考资料。所以它似乎不适合。
  • 我看到了使用 CodeFile 而不是 CodeBehind 的建议,并且还清除了 bin 文件夹。您需要尝试一些事情,这似乎是一个错误
  • 我已经清除了 bin 文件。但是 CodeFile 不是一个选项,因为它不是预编译代码,因此不是服务器上的源文件站点。这违反了我们的安全政策。

标签: asp.net webforms


【解决方案1】:

我仍然不知道为什么会这样。但我认为designer.vb文件不知何故损坏了。

所以我将标记和代码隐藏文件的内容复制到一个文本文件中。

然后我从项目中删除了整个用户控件并保存并清理了应用程序。

然后我从头开始添加用户控件并保存。

最后,我将标记的内容和后面的代码复制回用户控件中,保存并编译。

现在向标记添加新控件工作正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多