ERROR - Make sure that the class defined in this code file matches the 'inherits'....

gec

Joined
Oct 1, 2006
Messages
1
Reaction score
0
I have a user control which inherits from a class named BaseChart which is located in the App_Code directory. Source code is:

BaseChart.cs

public abstract class BaseChart : System.Web.UI.UserControl
{
WebChartViewer ChartViewer;

protected void Page_Load(object sender, EventArgs e)
{
...
}
}

GenericChart.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="GenericChart.ascx.cs" Inherits="UserControls_GenericChart" CodeFileBaseClass="BaseChart" %>

GenericChart.asc.cs

public partial class UserControls_GenericChart : BaseChart
{

}


Now that above code compiles perfectly ok. The problems begin when I add an instance of the WebChartViewer control into the GenericChart.ascx. The WebchartViewer is a 3rd party component.

Updated GenericChart.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="GenericChart.ascx.cs" Inherits="UserControls_GenericChart" CodeFileBaseClass="BaseChart" %>
<%@ Register Assembly="netchartdir" Namespace="ChartDirector" TagPrefix="chart" %>
<chart:WebChartViewer ID="ChartViewer" runat="server" />

The addition of these two extra lines of code will cause the compile 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).

I have added ASP.NET server controls to the GenericChart.ascx file without causing this compile error which appears to be generated from this particular control which is located in a separate assembly.

I have scoured the forums for a solution to this and have already tried and failed with the following recommended solutions:

- stop IIS, delete Temp ASP.NET files and try again
- Added the control tag prefix to the <controls> in the web.config file


Can anyone help?


gec.
 
Joined
Jun 26, 2008
Messages
1
Reaction score
0
Hello gec
You are using a thirdparty dll netchartdir.dll. for webchartviewer. in that dll you might be having BaseChart class.
that's why it is giving u the compilation error.
change you BaseChart class name to someother name it will work.

hope this solves your problem

Srinivas.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top