编译时出现:请确保此代码文件中定义的类与“inherits”属性匹配,并且该类扩展的基类(例如 Page 或 UserControl)是正确的

来源:互联网 发布:seo推广工具 编辑:程序博客网 时间:2024/06/05 16:51
 

编译ASP.NET时,提示“请确保此代码文件中定义的类与“inherits”属性匹配,并且该类扩展的基类(

例如Page 或UserControl)是正确的。”,

1.aspx页面中的inherits的命名和aspx.cs中的代码里类名不一致(一般因为这两种页面其中有一个页面修改过,或者全部复制其他的页面代码)

2.可能自己加过命名空间,去掉后编译正常,但是我希望加入命名空间,解决方式:在ASPX页面中的inherits后加入命名空间的名称,比如原来是inherits="index",命名空间为category,现在改成inherits="category.index"即可

3. 检查用户空间所引用的类是否正确
  public class ST_ModuleBase : System.Web.UI.UserControl
    {
        public ST_ModuleBase()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
原创粉丝点击