472,119 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Compile error: Make sure that the class defined in this code file.

I've created a project from Microsoft's "club.vsi". I don't want inline code
so I've separated all aspx and ascx pages into code-behind pages. I'm
compiling the project and continue to get this error:

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). It is referring to "LoginBanner" on the first line of the code

public partial class LoginBanner : System.Web.UI.UserControl
protected void Logoutbtn_Click(object sender, System.EventArgs e)

This error has plagued my project. It bounces around from ASCX control to
control without any way to predict which it will pick on. I have tried
several suggestions obtained by googling with no success. I do not know what
I've done wrong to cause the compiler to act like this.

I've even tried fully-qualifying the "inherits=" by adding the file name
containing the control, e.g.:

<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="LoginBanner.ascx.cs" Inherits="LoginBanner.LoginBanner" %>

Notice "LoginBanner.LoginBanner". What is really amazing is that I could
change this to:

<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="LoginBanner.ascx.cs" Inherits="LoginBannerXYZ.LoginBanner" %>

and it doesn't complain. It just finds another ASCX control complains about
it the same way. It doesn't even care that LoginBannerXYZ.LoginBanner is

Sep 8 '06 #1
1 1892
Hello Larry,

From your description, when you tried modifying the ASP.NET "club" starter
kit's page/usercontrol to make it use separate code-behind file, it
reported some "Compile error: Make sure that the class defined in this code
file..........." error, correct?

Based on my experience, though the error message is quite straightforward,
the actual cause is likely due to some other related compilation setting or
referenced page/usercontrol components.

For the error, would you please paste the complete exception source and

Also, since the starter-kit contains many different pages and component
classes, I would suggest you tried isolate the problem by create a
simplifid project whch only contain one or two pages(or with a related
usercontrol) that can reproduct the exact same error behavior. If so, we
can concentrate on that simplief project. If you feel it convenient, you
can send the project to me so that I can perform some local test against it.


Steven Cheng

Microsoft MSDN Online Support Lead


Get notification to my posts through email? Please refer to

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at


This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 11 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by newbiecpp | last post: by
4 posts views Thread by Seok Bee | last post: by
1 post views Thread by electrixnow | last post: by
8 posts views Thread by mastermagrath | last post: by
11 posts views Thread by Tim H | last post: by
reply views Thread by tshad | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.