我最近继承了另一个供应商的项目,我正在尝试将其转变为可用的Visual Studio 2010解决方案。
我目前遇到的错误是:
确保此代码文件中定义的类与 'inherits'属性,并且它扩展了正确的基类(例如 Page或UserControl)。
我发现这个问题还有其他几个问题,但在这种情况下似乎没有一个解决方案可行。以下是有问题的代码:
〜/布局/ 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);
}
}
}
〜/布局/ 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继承,并且似乎没有任何问题。
答案 0 :(得分:0)
我认为问题在于您的命名空间名称以您的类名结尾:
namespace Layouts.layouts_Header
{
public partial class layouts_Header // * snip *
尝试从命名空间中删除layouts_Header
部分,然后将Inherits
属性的值更改为Layouts.layouts_Header
答案 1 :(得分:0)
似乎提供给我的解决方案包含一个文件夹结构:
/温度/ installation_history / 681FBB6D58774C7D96B37D1353B7441E /布局
包含Header.ascx和Header.ascx.cs的副本。当我从项目中排除Header.ascx和Header.ascx.cs中的实际副本时,我发现了这些文件。
删除临时文件夹及其所有内容后,解决方案已编译完毕。谢谢大家的建议。