我最近继承了另一个供应商的项目,我正试图将它变成一个可用的 Visual Studio 2010 解决方案。
我目前遇到的错误是:
确保此代码文件中定义的类与'inherits' 属性匹配,并且它扩展了正确的基类(例如Page 或UserControl)。
我发现这个问题已经多次提出,但在这种情况下似乎没有一个解决方案有效。以下是有问题的代码:
~/layouts/Header.ascx.cs
using System;
using Client._Classes.Global;
using Client._Classes.Helpers;
using Client._Classes.Utilities;
namespace Layouts.layouts_Header
{
public partial class layouts_Header : BaseControl
{
private void Page_Load(object sender, EventArgs e)
{
}
protected void lnkSignIn_OnClick(object sender, EventArgs e)
{
Session["CurrentPageURL"] = Sitecore.Context.RawUrl;
Response.Redirect("/en/Community/Register.aspx");
}
protected void btnSearchSubmit_OnClick(object sender, EventArgs e)
{
string redirectURL = "/en/Search%20Results.aspx?cx=005917832522243245879:kpcudcaotoo&cof=FORID:11&ie=UTF-8&q=" + txtSearchQueryStr.Text;
Response.Redirect(redirectURL);
}
}
}
~/layouts/Header.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="~/layouts/Header.ascx.cs" Inherits="Layouts.layouts_Header.layouts_Header" %>
BaseControl.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Globalization;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Web;
using Sitecore.SharedSource.Data.Comparers.ItemComparers;
using Sitecore.Data.Fields;
using Sitecore.SharedSource.Searcher;
using Sitecore.SharedSource.Searcher.Parameters;
using Sitecore.SharedSource.Searcher.Utilities;
using Sitecore.Collections;
using Client._Classes.Utilities;
using Client._Classes.Helpers;
using Client._Classes.Global;
namespace Client._Classes.Global
{
public class BaseControl : System.Web.UI.UserControl
{
...
}
}
应该注意的是,其他几个 .ascx 控件也继承自 BaseControl,并且似乎没有任何问题。