If you recently did an upgrade of a project from VS.NET 2008 to 2010 that contained the Microsoft Charting controls for .NET, then you probably encountered some errors upon 1st run if you are now targeting the .NET Framework 4.0. The solution is to upgrade the charting references to the new .dll version throughout the application.
One possible exception you may have encountered immediately is the following:
"'Legend' is ambiguous in the namespace 'System.Web.UI.DataVisualization.Charting'."
This all points to the need to update the references to the 220.127.116.11 version of the System.Web.DataVisualization.dll used by the MS Chart controls. The following steps need to be completed to get your project current and working with the 4.0 version of the Chart controls.
1. Remove the reference to the System.Web.DataVisualization .dll in the project. If just converted it will still be referencing the 18.104.22.168 version of the .dll.
2. Add a reference to the new 22.214.171.124 version of the .dll from the '.NET' tab when adding a reference to your project. You can view the 'Version' column to make sure you have the correct reference.
3. In the web.config, update the version number in the 'Controls' tag from 126.96.36.199 to 188.8.131.52. Nothing else needs to be modified; the PublicKeyToken, etc. are all the same. Just change the version number. The corrected configuration is displayed below:
4. In the web.config, update the version number in the 'assembly' tag for the System.Web.DataVisualization reference from 184.108.40.206 to 220.127.116.11 if not already done. This may have been updated when adding the reference in Step #2, but if not go ahead and modify it now. The corrected configuration is displayed below:
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=18.104.22.168, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
5. In the web.config, update the 'httpHandlers' section for "ChartImg.axd" version once again from 22.214.171.124 to 126.96.36.199. The corrected configuration is displayed below:
<add assembly="System.Web.DataVisualization, Version=188.8.131.52, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
6. In the markup of any page using the Chart controls, remove the page registration for the assembly; just delete it. The next step will add back in the proper registration.
<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=184.108.40.206, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
7. From the 'ToolBox' under the 'Data' tab, drag a 'Chart' control onto your existing page. This simple method will create the proper registration at the top of the page. Make sure to modify the 'TagPrefix' to the proper value if you had changed it previously from the default 'asp' used. After the registration is added back to the page, you can delete the chart control dragged on the page; it was just used to create the proper registration (this happens whenever a new control is dragged onto a page). Repeat this step for any pages that have a chart control on them. The proper page registration is shown below:
8. Rebuild your solution and run it. Your MS Chart controls should now be displayed properly!
<%@ Register Assembly="System.Web.DataVisualization, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
As an additional reference, the MS Chart samples for .NET have been updated for the .NET Framework 4.0. If you have any additional problems, download the samples project and view the code or markup. You can find the samples at the following link:
Samples Environment for .NET Framework 4 Chart Controls Released!