I'm trying to return a chart to an MVC ActionResult as the view's Model but am hitting the following error:
CS0012: The type 'System.Web.UI.DataVisualization.Charting.Chart' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
The project I'm writing is in MVC3, using Razor as the front-end markup (which shouldn't make any difference, right?). I've included the following declarations in my Web.Config
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<!-- Microsoft Chart Controls -->
<add name="ChartImg" path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="ReportViewerWebControl" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
</system.webServer>
My ActionResult code is pretty vanilla:
[HttpGet]
public ActionResult Visits()
{
StatModel model = new StatModel();
return View(model);
}
And the view in question looks like this:
@foreach (Chart chart in Model.ColumnCharts)
{
@chart
}
From what I'm reading about the exception being returned, the problem is that the Chart type isn't being picked up correctly by the view when it comes to rendering the image, but the System.Web.DataVisualisation assembly appears in my project references (v. 4.0.0.0). What else should I be looking at?