Visual Studio 2010 with .NET 4.0 does not recognize System.Web.UI.DataVisualization.Charting

I am using Visual Studio 2010 with .NET 4.0.

I just started using MS graphics. When I execute the project, I get the following error:

The type or namespace name 'DataVisualization' does not exist in the namespace 'System.Web.UI' (are you missing an assembly reference?) 

In addition, in my code, this line has a line below it, indicating that the namespace cannot be found:

 using System.Web.UI.DataVisualization.Charting; 

However, if I go to my local host on a page that has a diagram, it displays fine.

Another strange thing: when I compile (CTRL + SHIFT + B), I get 3 compilation errors on the first compilation, then when I do it again, right after that, I get 16.

Despite the fact that I get compilation errors above, I can still run the application and everything works fine, but it is really annoying that it will not compile, so I have to do something wrong.

Any help with this would be greatly appreciated.

Thanks.

+4
source share
8 answers

Unfortunately, all this did not work. I finished creating a completely new solution and added all the code and it worked correctly. There must have been some kind of gremlin that I could not find.

+1
source

Ok, figured out the problem.

I looked at Google ... StackOverflow and found this page, but I knew that the problem did not need to be fixed, starting with.

I have ALL links and fixed web.config and I still have an error.

The answer is to change the .Designer code from

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

to

 protected global::System.Web.UI.DataVisualization.Charting.Chart chartDailyVolume; 

I copied and pasted the code from another visual studio 2010 project onto the page, and the designer actually linked it incorrectly. When I dragged another diagram onto the page and then deleted it and compiled in order, I compared my tested code with TFS with a new fix. Thus, I noticed that Designer.cs actually worked incorrectly with copy and paste, although both of them were visual studio 2010 solution projects (as with Target Framework.NET Framework 4).

+7
source

Click Add Links in your project, and on the .NET Components tab, add System.Web.DataVisualization . This should solve your problem.

+5
source

add a link to System.Web.DataVisualization.dll and add a chart control to your page and remove the control to create web.config settings, etc.

Check these enteries in Web.config .. if they are available then it should work well.

 <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> 

2.

 <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 

3.

  <httpHandlers> <add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/> </httpHandlers> 
+2
source

Have you added the DLL as a link to your web project? It looks like you included it only in the bin folder or something like that.

0
source

In the "Project Links" section, add System.Web.DataVisualization.dll

Even if I get the compilation errors above, I can still run the application and everything works fine, but it is really annoying that it will not compile, so I have to do something wrong.

Your actual code is not the one that works, as it does not compile. If the executable instance is still working correctly than the dll, it is probably located somewhere in the bin folder where your exe file is located.

0
source

This solution (creating a new project) worked for me. Unlike many other people with this problem, I did not use the constructor and did not use web.config (desktop application). Play a new project and then add a link, and I was able to reference components and methods.

“Unfortunately, none of this worked. I finished creating a completely new solution and added all the code, and it worked correctly. There must have been some kind of gremlin that I could not find.

0
source

I finished creating a completely new solution and added all the code and it worked properly. There must have been some kind of gremlin where I could not be found.

Your gremlin most likely lived in the page designer file invoking the control. That was my business. The cause of the problem was editing the .aspx file and adding control while the debugger was running - designer files cannot be edited in this mode. You must disable the debugger to add controls.

After fixing, rebuild the solution to fix your DLL files.

Yes, starting from scratch, fixing a visual studio hiccup in the designer file, but this is not always an option.

0
source

Source: https://habr.com/ru/post/1383176/


All Articles