3

I've upgraded a web application from .NET 3.5 to .NET 4, and I get this exception when browsing to a page that uses the Chart control:

The type 'System.Web.UI.DataVisualization.Charting.Grid' exists in both 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.DataVisualization\v4.0_4.0.0.0__...\System.Web.DataVisualization.dll' and 'c:\Windows\assembly\GAC_MSIL\System.Web.DataVisualization\3.5.0.0__...\System.Web.DataVisualization.dll'

How can I get this working, using the 4.0 control? Thanks.

Martin Buberl
  • 45,844
  • 25
  • 100
  • 144
hmqcnoesy
  • 4,165
  • 3
  • 31
  • 47

3 Answers3

4

1) Upgrade all references that point to the 3.5 Chart control in web.config to reference version 4:

tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" ... Version=4.0.0.0 ...

add path="ChartImg.axd" verb="GET,HEAD,POST" ... Version=4.0.0.0 ...

add name="ChartImageHandler" ... Version=4.0.0.0 ...

2) Remove all charting libs from your Bin directory because they are already included in the .NET 4 framework

Gianpiero
  • 3,349
  • 1
  • 29
  • 42
3

You can use assembly redirection.

For example (make sure the publicKeyToken is correct, I don't have the assembly on this computer):

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <dependentAssembly>
            <assemblyIdentity name="System.Web.DataVisualization"
                              publicKeyToken="32ab4ba45e0a69a1"
                              culture="neutral" />
            <bindingRedirect oldVersion="3.5.0.0"
                             newVersion="4.0.0.0"/>
         </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>
Oded
  • 489,969
  • 99
  • 883
  • 1,009
0

Remove one of them , one is in the GAC and one is in your project i guees.

Maybe you have a reference in your project that is left after you used. NET 3.5? Or other DLLs that use it: =)

eriksv88
  • 3,482
  • 3
  • 31
  • 50