The designer insists on "System.Web.UI.WebControls", which is not

I ran into an odd problem: I am trying to port an ASP.NET 4.0 website to an ASP.NET web application. The Visual Studio function "Convert to Web Application" really worked pretty well, but the only thing that doesn't work is the links to the charts. I get an error message:

The type or name of the Chart namespace does not exist in the namespace 'System.Web.UI.WebControls'

From the .designer file. The designer automatically creates this type of code:

protected global::System.Web.UI.WebControls.Chart ClientHoursPie;

Based on my research, the correct 4.0 namespace to use for charts is System.Web.UI.DataVisualization.Charting. I added the following components to web.config (copied from the original site, which worked fine):

<httpHandlers>
    <add 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" validate="false"/>
</httpHandlers>
<compilation debug="true" targetFramework="4.0">
    <assemblies>
        <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </assemblies>
</compilation>

I can fix the namespaces in the constructor files, but every time the aspx file is saved, the designer goes back to the old namespace.

I would like to avoid having to rebuild all individual pages from scratch. Is there somewhere somewhere that I missed?

Thanks in advance.

+3
source share
1 answer

I was able to solve the problem by adding some entries to web.config that I skipped. Anyone experiencing this issue should make sure you include:

<pages>
    <controls>
        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </controls>
</pages>

( system.webServer):

<handlers>
    <remove name="ChartImageHandler"/>
    <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
+1

All Articles