By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,025 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,025 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
below.

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

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
nonsense.

Thanks
Sep 8 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
callstack?

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.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

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
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

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.