Missing directive or assembly reference?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brandon S
    New Member
    • Dec 2010
    • 2

    Missing directive or assembly reference?

    Code:
     private void okButton_Click(object sender, EventArgs e)
            {
                HelloForm aHelloForm = new HelloForm();
                aHelloForm.Show();
    
            }
    As part of my intro to C# class I'm working on multiform project. However, while trying to use the general form of the show method above, I'm getting the error Error 2 The type or namespace name 'HelloForm' could not be found (are you missing a using directive or an assembly reference?) and can't seem to resolve it. I'm using Visual Studio C# Express and have already added the HelloForm to the project from the 'add existing item' option. What am I doing wrong? My instructor is not very good at solving errors like this.
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    Error 2 The type or namespace name 'HelloForm' could not be found (are you missing a using directive or an assembly reference?)
    I'm willing to bet you're missing a using directive. Once you add the assembly reference, you also need a using statement at the top so your program knows what namespace the control lives in.

    Alternatively, you could use the fully qualified name, which is the namespace followed by the object, to declare it.

    You'll have to find out what the namespace is, then put a using directive at the top of your code file.

    Comment

    • Brandon S
      New Member
      • Dec 2010
      • 2

      #3
      Thanks a million man. At first I had no idea what you meant but did some further research to understand it better, and I was able to resolve it. I was missing a using directive (which I am now more familiar with) and can now continue my project.

      Comment

      Working...