AndrWeisR
AndrWeisR

Reputation: 1226

Visual Studio 2017 can't reference System.Windows.Forms.DataVisualization

I have migrated a VS 2008 project to Visual Studio 2017 community edition. The project uses .net charts, and was originally a .net 3.5 project. I now have .net framework 4.7.2 installed.

I am unable to add a reference to System.Windows.Forms.DataVisualization in the project references. When I select System.Windows.Forms.DataVisualization from the available references, it is added to the project references but it has a yellow warning icon next to it, and the compiler can't find the classes in the DataVisualization namespace.

I found this article with a supposed fix: https://developercommunity.visualstudio.com/content/problem/28126/unable-to-add-reference-in-visual-studio-2017-refe.html

This mentions the command gacutil -i System.Windows.Forms.DataVisualization.dll. When I run this command in the Developer Command Prompt for VS 2017, I get an error:

Failure adding assembly to the cache: An attempt was made to load a program with an incorrect format.

What's the trick to getting charts to work in .net 4.7?

Upvotes: 2

Views: 3898

Answers (2)

Vere
Vere

Reputation: 11

  1. You have to be using a Windows Forms Application project
  2. You have to put a chart control onto your form. You know like go to the toolbox, type chart into the search bar and drag a chart onto your form, otherwise you will never be able to reference the .datavisualization.charting namespace. I made the same mistake and thats what brought me here lol.

Upvotes: 1

Related Questions