.net - ASP.NET 2.0编译错误: Make sure that the class defined in this code file matches the 'inherits' attribute

标签 .net asp.net .net-2.0 code-behind

好吧,我完全陷入了这个编译错误。这是一个网站(不是 Web 应用程序),.NET 2.0。

我在此目录中有一个文件:welcome_teams

文件名:default.aspx

页面声明:

<%@ Page Language="C#" MasterPageFile="~/masters/Site.master" 
AutoEventWireup="true"    CodeFile="default.aspx.cs" 
Inherits="welcome_teams_default" %>`

隐藏代码

public partial class welcome_teams_default : System.Web.UI.Page

我不断收到此错误: 确保此代码文件中定义的类与“inherits”属性匹配

我尝试删除该文件,然后将其再次添加为“新项目”,但无论如何,错误仍然存​​在。

有什么想法吗?

谢谢!

最佳答案

所以,它与命名空间无关,它与default2.aspx页面有关,指向default.aspx页面。

default2.aspx 页面的 CodeFile 属性被设置为“default.aspx.cs”,这把一切搞砸了。

对于将来可能遇到此问题的任何人,有时可以通过将 CodeFile 更改为 CodeBehind 来解决它。

此外,理论上这是一个命名空间问题,但天哪,我讨厌网站项目如何处理命名空间。

关于.net - ASP.NET 2.0编译错误: Make sure that the class defined in this code file matches the 'inherits' attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1088204/

相关文章:

c# - 有时线程没有启动

c# - 如何制作安全的登录页面、搜索功能

asp.net - 在 SQL 查询中使用 LIKE

c# - .Net UserControl 的设计问题

c# - WinForms ListView.HideSelection 属性没有效果?

c# - Unity.MVC 无法使用参数解析我的 Controller 构造函数

c# - 如何在ASP.NET中运行SSIS

c# - 尝试连接到 unity3d 中启用 TLS 的代理时 MQTT 超时

c# - 错误“JavaScript 运行时错误 : Unable to get property 'scrollLeft' of undefined or null reference"while finding scroll position

c# - 如何从 XmlNode 实例获取 xpath