You are here:

C#/C# chart controls

Advertisement


Question
Sir,
I am creating a chart form and trying to create a chart object that keeps giving me error

" Error   8   The type or namespace name 'Chart' does not exist in the namespace 'System.Windows.Forms.DataVisualization.Charting' (are you missing an assembly reference?)"

with the following line

"private System.Windows.Forms.DataVisualization.Charting.Chart chart1;"

i am trying to create chart1 as an object of chart.
i have done a bit of searching and another syntax available has form of

"System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();"

i am using vs 2012 .NET 4.5
i created a form by dragging and dropping chart control from toolbox which automatically generated the second syntax but when i try the same code its an error, plus while writing my code vs 2012 prompts for "...Charting.Utilities" and never shows "ChartArea" as an option.
but when i drag and drop that time it works fine.

please do help me i am fixed.

regards,
Prakash.

Answer
Hi there,

Check if you have reference to System.Windows.Forms.DataVisualization. If you don't have it, add it and it will work fine. If you have it, ensure your project's .Net version is 4 or 4.5. Go to project properties and see Target Framework to confirm it. (Even you pointed that you use 4.5, please re-confirm it, mistakes may happen)

Hope that helps,

Murat

C#

All Answers


Answers by Expert:


Ask Experts

Volunteer


Murat Mehmet

Expertise

I can help with questions about desktop and web programming in C#, including SOAP, XML, database managing, custom controls, security etc.

Experience

I have been developing web and especially desktop applications in C# and VB.Net for almost 5 years. My programming life has begun with VB6 long time ago, so its about 8 years that I am in this business.

Organizations
Was in R & D for 2 years in a popular Turkish technology website: cyber-warrior.com

Education/Credentials
2011 Computer Engineering graduation in University of Trakia in Turkey.

©2016 About.com. All rights reserved.