Error 4 Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

asp.net India
  • 12 years ago

    I have a ASP.NET 2.0 Web application and I have added a Default.aspx page to the application.

    I have developed a set of class libraries specifying a namespace for them. I wanted my Web app to be included in the same namespace and so after creating the web app, I included the web application _Default partial class with a namespace.

    So my Default.aspx.cs looked like this

    namespace XYZ

    {

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

     {

       //Page Load and other methods go here

     }

    }

    Now when i try to build the application I get the following errors

     Error      1          'ASP.bulkassigntbm_aspx.GetTypeHashCode()': no suitable method found to override            c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\bulkassigntbm\2381c4a1\2068f9c4\App_Web_3pclp8a6.0.cs      6431      Error      2          'ASP.bulkassigntbm_aspx.ProcessRequest(System.Web.HttpContext)': no suitable method found to override            c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\bulkassigntbm\2381c4a1\2068f9c4\App_Web_3pclp8a6.0.cs      6435      Error      3          'ASP.bulkassigntbm_aspx' does not implement interface member 'System.Web.IHttpHandler.IsReusable'            c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\bulkassigntbm\2381c4a1\2068f9c4\App_Web_3pclp8a6.0.cs      549          

    Error      4          Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).  13         33          

     

    What can be the possible error?

     

     

  • 12 years ago

    After analysing the error messages and zeroing in on the Error 4: class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class

    I identified that there is a problem  in the html source of the web form

    When I saw the html source's Page tag it was

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

    The inherits attribute only has the class name and there is no reference to the namespace XYZ in which the class is contained.

    When the attribute value was changes to

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="XYZ._Default" %>

    the project build succeeded.

    Big Smile

     

  • 12 years ago

    Make note that, when the solution is first built, the Error 4 will not appear in the Errors list

    Only the following errors appear

    Error     5          'ASP.bulkassigntbm_aspx.GetTypeHashCode()': no suitable method found to override            c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\bulkupdateprototype\a80cfc30\f6ae94f0\App_Web_wcvj1dpb.0.cs       6587      
    Error     6          'ASP.bulkassigntbm_aspx.ProcessRequest(System.Web.HttpContext)': no suitable method found to override            c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\bulkupdateprototype\a80cfc30\f6ae94f0\App_Web_wcvj1dpb.0.cs       6592      
    Error     7          'ASP.bulkassigntbm_aspx' does not implement interface member 'System.Web.IHttpHandler.IsReusable'            c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\bulkupdateprototype\a80cfc30\f6ae94f0\App_Web_wcvj1dpb.0.cs       549      

    Regards

  • 12 years ago
    Changing the attribute from "codefile" to "codebehind", should do the trick. I found the related article here. http://codeguru302.blogspot.com

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” - Donald Knuth