微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

尝试运行ASP.NET应用程序时解析错误

如何解决尝试运行ASP.NET应用程序时解析错误

我正在尝试运行ASP.NET应用程序,但是在我的页面加载时显示如下:

Server Error in '/' Application.
Parser Error
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 'CMSMessages_Error'.

Source Error:


Line 1:  <%@ Page Language="C#" AutoEventWireup="true" Inherits="CMSMessages_Error"
Line 2:      Theme="Default"  Codebehind="Error.aspx.cs" %>
Line 3:  <%@ Register src="~/CMSAdminControls/UI/PageElements/PageTitle.ascx" tagname="PageTitle" tagprefix="cms" %>

Source File: /CMSMessages/error.aspx    Line: 1

Version information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4261.0

enter image description here

这是与我认为导致错误页面相关的代码

PageTitle.ascx

<%@ Control Language="C#" AutoEventWireup="true"  Codebehind="PageTitle.ascx.cs" Inherits="CMSAdminControls_UI_PageElements_PageTitle" %>

<%@ Register Src="~/CMSAdminControls/UI/PageElements/Help.ascx" TagName="Help" TagPrefix="cms" %>
<%@ Register Src="~/CMSAdminControls/UI/PageElements/BreadCrumbs.ascx" TagName="Breadcrumbs" TagPrefix="cms" %>

<asp:Panel runat="server" ID="pnlBody">
    <asp:Panel runat="server" ID="pnlTitle" CssClass="dialog-header non-selectable" Visible="false">
        <div class="dialog-header-action-buttons">
            <div class="action-button">
                <cms:Help ID="helpElem" runat="server" IconCssClass="cms-icon-80" />
            </div>
            <asp:PlaceHolder runat="server" ID="plcMisc" />
            <asp:Panel runat="server" ID="pnlMaximize" CssClass="action-button" Visible="False" EnableViewState="False">
                <a>
                    <span class="sr-only"><%= GetString("general.fullscreen") %></span>
                    <i id="btnMaximize" runat="server" class="icon-modal-maximize cms-icon-80" aria-hidden="true"></i>
                </a>
            </asp:Panel>
            <asp:Panel runat="server" ID="pnlClose" CssClass="action-button close-button" Visible="False" EnableViewState="False">
                <a>
                    <span class="sr-only"><%= GetString("general.close") %></span>
                    <i id="btnClose" runat="server" class="icon-modal-close cms-icon-150" aria-hidden="true"></i>
                </a>
            </asp:Panel>
        </div>
        <cms:Localizedheading runat="server" ID="headTitle" CssClass="dialog-header-title" EnableViewState="false" />
        <asp:Label ID="lblTitleInfo" runat="server" CssClass="PageTitleInfo" EnableViewState="false" Visible="false" />
    </asp:Panel>
    <cms:Breadcrumbs ID="breadcrumbs" runat="server" />
</asp:Panel>

PageTitle.ascx.cs

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

using CMS.Base.Web.UI;
using CMS.DataEngine;
using CMS.DeviceProfiles;
using CMS.Helpers;
using CMS.UIControls;


public partial class CMSAdminControls_UI_PageElements_PageTitle : PageTitle
{
    #region "Public properties"

    /// <summary>
    /// Breadcrumbs control
    /// </summary>
    public override Breadcrumbs Breadcrumbs
    {
        get
        {
            return breadcrumbs;
        }
    }


    /// <summary>
    /// Title CSS class.
    /// </summary>
    public override string TitleCssClass
    {
        get
        {
            return pnlTitle.CssClass;
        }
        set
        {
            pnlTitle.CssClass = value;
        }
    }


    /// <summary>
    /// Topic name can be either a perma link,or absolute URL.
    /// </summary>
    public override string HelpTopicName
    {
        get
        {
            return helpElem.TopicName;
        }
        set
        {
            helpElem.TopicName = value;
            breadcrumbs.Help.TopicName = value;
        }
    }


    /// <summary>
    /// Help name to identify the help within the javascript.
    /// </summary>
    public override string HelpName
    {
        get
        {
            return helpElem.HelpName;
        }
        set
        {
            helpElem.HelpName = value;
            breadcrumbs.Help.HelpName = value;
        }
    }


    /// <summary>
    /// Help icon name for title.
    /// </summary>
    public override string HelpIconName
    {
        get
        {
            return helpElem.IconName;
        }
        set
        {
            helpElem.IconName = value;
        }
    }


    /// <summary>
    /// Placeholder after image and title text.
    /// </summary>
    public override PlaceHolder RightPlaceHolder
    {
        get
        {
            return plcMisc;
        }
        set
        {
            plcMisc = value;
        }
    }

    #endregion


    #region "Dialog properties"

    /// <summary>
    /// Indicates if the control should use the string from resource file.
    /// </summary>
    public bool UseFileStrings
    {
        get;
        set;
    }

    #endregion


    #region "Page events"

    protected void Page_PreRender(object sender,EventArgs e)
    {
        if (StopProcessing)
        {
            return;
        }

        // Register jQuery
        ScriptHelper.RegisterJQuery(Page);

        // Use dark help icon for dialogs
        helpElem.IsDialog = IsDialog;

        // Set breadcrumbs visibility
        breadcrumbs.HideBreadcrumbs = HideBreadcrumbs;

        // Set level of h element
        headTitle.Level = headingLevel;

        // Set the title text if set
        if (!string.IsNullOrEmpty(TitleText))
        {
            if (!HideTitle)
            {
                pnlTitle.Visible = true;
                headTitle.Text = TitleText;
            }
        }
        else
        {
            pnlTitle.Visible = false;
            breadcrumbs.Help.Visible = true;
        }

        // Set the title info if set
        if (!string.IsNullOrEmpty(Titleinformation))
        {
            lblTitleInfo.Text = Titleinformation;
            lblTitleInfo.Visible = true;
        }

        // Register scripts only when needed
        if (pnlTitle.Visible)
        {
            EnsureFullScreenButton();

            EnsureCloseButton();

            EnsureDraggable();
        }

        if (!Wrap)
        {
            headTitle.Style.Add("white-space","Nowrap");
        }
    }

    #endregion


    #region "Methods"

    private void EnsureDraggable()
    {
        // Load draggable iframe script
        ScriptHelper.RegisterScriptFile(Page,"DragAndDrop/dragiframe.js");

        ScriptHelper.RegisterGetTopScript(Page);

        // Initialize draggable behavior
        ScriptHelper.RegisterStartupScript(this,typeof (string),"draggableFrame",ScriptHelper.GetScript(
@"$cmsj(window).load(function(){
var topFrame = GetTop();
if(window.wopener)
{
    if((top.isTitleWindow) && top.isTitleWindow(topFrame,window))
    {
        addHandle(document.getElementById('" + pnlTitle.ClientID + @"'),window);
    }
}
});"));
    }


    private void EnsureFullScreenButton()
    {
        if (ShowFullScreenButton && IsDialog)
        {
            pnlMaximize.Visible = true;
            btnMaximize.Attributes.Add("onclick","return fs_" + ClientID + "($cmsj(this));");
            btnMaximize.Style.Add(HtmlTextWriterStyle.Cursor,"pointer");
            string fsToolTip = GetString("general.fullscreen");
            btnMaximize.Attributes.Add("title",fsToolTip);

            //Call PageTitle's GetString (no reshelper) - fix problem with no DB connection avaible
            string fullScreenScript = @"
function titleFullScreen(sender)
{
    if(top.toggleFullScreen)
    {
        top.toggleFullScreen();
        toggleFullScreenIcon(sender);
    }
    return false;
}

function toggleFullScreenIcon(sender)
{
    var btn = sender;
    btn.toggleClass('icon-modal-maximize');
    btn.toggleClass('icon-modal-minimize');
    if(btn.hasClass('icon-modal-minimize'))
    {
        sender.attr('title'," + ScriptHelper.GetString(GetString("general.restore")) + @");
    }
    else
    {
        sender.attr('title','" + fsToolTip + @"');
    }
}";
            ScriptHelper.RegisterClientScriptBlock(this,typeof(string),"fullScreenScript",ScriptHelper.GetScript(fullScreenScript));

            // Register fullscreen button for new dialogs
            string fsVar = @"
function fs_" + ClientID + @"(sender)
{
    return titleFullScreen(sender);
}";
            ScriptHelper.RegisterClientScriptBlock(this,"fsVar_" + ClientID,ScriptHelper.GetScript(fsVar));

            string fsInit = @"
$cmsj(document).ready(function(){
    if(window.wopener && (top != null) && top.$visiblePopup)
    {  
        var topFrame = GetTop();
        if(top.isTitleWindow(topFrame,window) && !topFrame.fullScreenButtonAvailable)
        {
            var fsButton = $cmsj('#" + btnMaximize.ClientID + @"');
            if(top.isFullScreen())
            {
                toggleFullScreenIcon(fsButton);
            }
            fsButton.show(); 
            $cmsj('#" + pnlBody.ClientID + @"').dblclick(function(){return fs_" + ClientID + @"(fsButton);});
            topFrame.setToFullScreen = function () { return !top.isFullScreen() ? fs_" + ClientID + @"(fsButton) : false; };
            topFrame.fullScreenButtonAvailable = true;
            $cmsj(window).unload(function() {
                topFrame.fullScreenButtonAvailable = false;
            });
        }
    }
});";
            ScriptHelper.RegisterClientScriptBlock(this,"fsInit_" + ClientID,ScriptHelper.GetScript(fsInit));
        }
    }


    private void EnsureCloseButton()
    {
        if (ShowCloseButton && (DeviceContext.CurrentDevice.IsMobile || IsDialog))
        {
            pnlClose.Visible = true;
            btnClose.Style.Add(HtmlTextWriterStyle.Cursor,"pointer");
            btnClose.Attributes.Add("title",GetString("general.close"));

            // Always close the window
            btnClose.Attributes["onclick"] += ";return CloseDialog();";
        }
    }


    /// <summary>
    /// Returns localized string.
    /// </summary>
    /// <param name="stringName">String to localize</param>
    /// <param name="culture">Culture</param>
    public override string GetString(string stringName,string culture = null)
    {
        if (UseFileStrings || !ConnectionHelper.ConnectionAvailable)
        {
            return ResHelper.GetFileString(stringName,culture);
        }

        return base.GetString(stringName,culture);
    }

    #endregion


    public void SetCloseJavaScript(string javaScript)
    {
        btnClose.Attributes.Add("onclick",javaScript);
    }
}

我对.NET不够熟悉,不知道该怎么办。我该如何解决这个问题?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。