views:

3614

answers:

4

Hi. 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. :\

A: 

Are you getting actual build errors or just squiggles? Try building and look at the output window, does it succeed or fail?

In VS 2008 SP1 C# introduced a top level error squiggling feature. It's possible that if you open the solution item version of the file it will squiggle because of a lack of default references. The solution should still build correctly though.

If this is not the case try adding the file directly to the project (no link). See if that eliminates the error. If so then we know it has to due with a linked file and it can help track down the problem.

JaredPar
The errors I'm seeing (second line of the question) occur when I'm building the solution.
jxpx777
@jxpx777 did you try adding the file directly?
JaredPar
A: 

Solution items aren't used by compiled assemblies.

http://msdn.microsoft.com/en-us/library/1ee8zw5t.aspx "They can be referenced by projects, but are never included in solution or project builds"

As far as I know, solution folders/items are really just meant for organizing things.

jayrdub
A: 

I had the same problem and it got resolved when i installed "Chart Controls to Visual Studio toolbox"

guest1
A: 

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.

Adam