Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Windows.Forms.DataVisualization Namespace Fine in One Class but Not in Another

I'm getting this error

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

Here is my using section of the class:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms.DataVisualization.Charting;
using System.Windows.Forms.DataVisualization.Charting.Borders3D;
using System.Windows.Forms.DataVisualization.Charting.ChartTypes;
using System.Windows.Forms.DataVisualization.Charting.Data;
using System.Windows.Forms.DataVisualization.Charting.Formulas;
using System.Windows.Forms.DataVisualization.Charting.Utilities;

namespace myNamespace {
    public class myClass {
        // Usual class stuff
    }
}

The thing is that I am using the same DataVisualization includes in another class. The only thing that I can think that is different is that the classes that are giving this missing namespace error are Solution Items rather than specific to a project. The projects reference them by link. Anyone have thoughts on what the problem is? I've installed the chart component, .Net 3.5 SP1, and the Chart Add-in for Visual Studio 2008.

UPDATE: I moved the items from Solution Items to be regular members of my project and I'm still seeing the same behavior.

UPDATE 2: Removing the items from the Solution Items and placing them under my project worked. Another project was still referencing the files which is why I didn't think it worked previously. I'm still curious, though, why I couldn't use the namespace when the classes were Solution Items but moving them underneath a project (with no modifications, mind you) instantly made them recognizable. :\

like image 999
jxpx777 Avatar asked Feb 20 '09 16:02

jxpx777


Video Answer


1 Answers

You are very likely missing a reference to the DataVisualization DLL. Note that although they share the namespace of System.Windows.Forms.dll, they aren't actually contained within it.

like image 177
Adam Houldsworth Avatar answered Nov 20 '22 04:11

Adam Houldsworth