adsense

Monday, October 17, 2011

Upgrading an ASP.NET 3.5 Web site that has a 3.5 Chart control to ASP.NET 4 requires changes to web.config and register directive

If you have used Microsoft Chart control in your VS 2008 project and upgraded to VS 2010 following steps should be followed to upgrade to Chart control 4.0 (Extracted from Visual Studio 2010 Read me).


Updgrading an ASP.NET 3.5 Web site that has a 3.5 Chart control to ASP.NET 4 will cause the following error on build:
Error 1 The type 'System.Web.UI.DataVisualization.Charting.Chart' exists in both 'c:\Windows\assembly\GAC_MSIL\System.Web.DataVisualization\3.5.0.0__31bf3856ad364e35\System.Web.DataVisualization.dll' and 'c:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.DataVisualization.dll' C:\Websites\Vs2008Sp1_Website_35_Cs_WithChart\Default.aspx 15
To resolve this issue:
References that still point to the 3.5 Chart control in web.config after upgrade must be updated to reference version 4.
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">lt;controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
......
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<remove name="ChartImageHandler"/>
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
</system.webServer>
......
Register directive in the Web forms page must be removed or updated to reference version 4.
<%@ Register assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>
The existing System.Web.DataVisualization assembly in the bin folder may have to be deleted because this assembly is part of the .NET Framework 4.


No comments:

Post a Comment