开发者

c# error The type or namespace name 'SampleMain' does not exist in the namespace

Error 7 The type or namespace name 'SampleMain' does not exist in the na开发者_如何学Pythonmespace 'System.Windows.Forms.DataVisualization.Charting.Utilities' (are you missing an assembly reference?)

i am getting this error on this line:

        System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm mainForm = (System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm)this.ParentForm;

what am i doing wrong?


If you need help figuring out the 'structure' of the namespaces, use the Object Browser from within Visual studio or use Reflector to view what's within the

System.Windows.Forms.DataVisualization.Charting.Utilities

namespace. This may help you gain an understanding as to what you can and cannot access within each.


I get this error when I have no reference to the library in the "References" folder in my project. Check and make sure you are referencing it by clicking on the + next to the References folder and expanding the list.

Some of the libraries require you to explicitly reference them, even if they are contained in a namespace you are already referencing.

Edit: Also, make sure that the namespace/class you are trying to use really exists.

Edit: 'SampleMain' may not even be a good object to use. Found this that suggests that you shouldn't reference sample environment classes: http://social.msdn.microsoft.com/Forums/en/MSWinWebChart/thread/26aac6f7-d3bf-492f-bb52-dc88477f1b1b


Did you add the dll reference to your project?

click on the + next to Reference to see if you have included the correct namespaces/assemblies


You're getting this error because you've referenced a type with the following name that the compiler cannot find

System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm

The most likely causes for this issue are

  1. It exists but it's in a DLL that you haven't referenced in this project. Check the references of the project and make sure the DLL that contains the type is listed
  2. The type name is simply incorrect. Could be a typo or a just a wrong namespace in the name.


The SampleMain type does not exist in System.Windows.Forms.DataVisualization.Charting.Utilities namespace.


Always check that you do not have one of your projects set to the client profile. That will cause this same sort of behavior.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜