I am working on a program in C# .NET 2010 using WinForms and am having difficulty inheriting the System.windows.Forms.DataVisualization.Charting.Chart class into a custom chart.
When I view the form in the Visual Studio designer, I get an error saying:
Could not find type 'ExpeView.ExpeDataChart'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.
The file ExpeDataChart.cs is part of this project, and whenever I compile and run the program, it works perfectly. This error only comes up in the designer view, making it impossible for me to edit the form through the GUI.
The file ExpeDataChart.cs looks like this (this is slimmed down, but gets the point across):
namespace ExpeView
{
public class ExpeDataChart : Chart
{
public ExpeDataChart()
{
MouseMove += SampleMouseMove;
MouseLeave += SampleMouseLeave;
MouseDoubleClick += SampleDoubleClick;
MouseDown += SampleMouseDown;
MouseUp += SampleMouseUp;
MouseEnter += SampleMouseEnter;
MouseLeave += SampleMouseLeave;
MouseWheel += SampleMouseWheel;
}
private void SampleMouseMove(object sender, MouseEventArgs e) { }
private void SampleMouseLeave(object sender, EventArgs e) { }
private void SampleDoubleClick(object sender, MouseEventArgs e) { }
private void SampleMouseDown(object sender, MouseEventArgs e) { }
private void SampleMouseUp(object sender, MouseEventArgs e) { }
private void SampleMouseEnter(object sender, EventArgs e) { }
private void SampleMouseWheel(object sender, MouseEventArgs e) { }
private void SampleZoomIn(int x) { }
private void SampleZoomOut() { }
}
}
What would cause it to not properly load in the designer, but still load properly when compiling? The call stack of the error is:
ExpeView FormExpeView.Designer.cs Line:438 Column:1 at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)
Chart
class. I did it in two ways (by adding a simple class that inheriting from Chart and by adding a User Control derived from Chart). I was able to add both of those to the form using the designer. I used VS 2010 Express and a console project with WinForms form (butI suppose this should not make any difference in this case). – Lukasz M