none
The type or namespace name 'Form1' could not be found (are you missing a using directive or an assembly reference?)

    Question

  • Hello everyone.  I copied/pasted code into my project from here:

    http://www.devproconnections.com/article/database-development/simplify-data-entry-with-autocomplete

    I set up a ComboBox and named it with the appropriate name.  Similarly, I set up two TextBoxes and named them appropriately.  Then, I pasted in the code.  Now, I hit F11, and get this error:

    The type or namespace name 'Form1' could not be found (are you missing a using directive or an assembly reference?)

    I've seen this error before, and I rigged it to work, but I never really figured it out.  I would expect VS 2010 to be smart enough to know that there was initially a Form1, and there is now a Form1.  So, honestly, why would this cause an error?  I start with a Form1; I have a Form1 now...how can this be an error?  More importantly, how can I resolve this error?  If I click on the red squiggle line under the 'Form1', I can click Options, and make a selection and the error goes away, but then nothing works.  Sorry, but this makes no sense.

    Can someone please help me get this working?


    Ryan Shuell


    • Edited by ryguy72 Friday, October 12, 2012 2:54 AM
    Friday, October 12, 2012 2:53 AM

Answers

  • Ryan,

    did you check that your namespace is the same as the namespace in the copied code (namespace WinAutoComplete) ?


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by ryguy72 Saturday, October 13, 2012 3:56 PM
    Friday, October 12, 2012 5:54 AM
  • Ryan,

    the code of the link you have posted did contain this namespace.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by ryguy72 Saturday, October 13, 2012 3:56 PM
    Friday, October 12, 2012 3:43 PM
  • Ryan,

    i just did your suggested Step 2 without any problem. I created a Winform project, switched to the code window and replaced in my code anything between :

    namespace WindowsFormsApplication1
    {
    
    
    
    }

    with the code from the article between:

    namespace WinAutoComplete
    {
    
    
    
    
    }
    

    Then i have added the controls like described and it did compile without a problem.

    By the namespace problem i have meant that you should replace the "namespace WinAutoComplete" ( if you have copied this also ) with the namesapce of your project.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by ryguy72 Saturday, October 13, 2012 3:56 PM
    Saturday, October 13, 2012 8:47 AM

All replies

  • Ryan,

    did you check that your namespace is the same as the namespace in the copied code (namespace WinAutoComplete) ?


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by ryguy72 Saturday, October 13, 2012 3:56 PM
    Friday, October 12, 2012 5:54 AM
  • Thanks, for the look, Heslacher.  What do you mean 'namespace WinAutoComplete'? 

    All I did was copy the code from that link and paste it behind my form.  Then I added a ComboBox and a couple TextBoxes, and named them appropriately.  That got rid of the few errors, as I would have expected, but then I got the error that I described above, when I hit F5.


    Ryan Shuell

    Friday, October 12, 2012 1:08 PM
  • Ryan,

    the code of the link you have posted did contain this namespace.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by ryguy72 Saturday, October 13, 2012 3:56 PM
    Friday, October 12, 2012 3:43 PM
  • Thanks guys!  So, I made a modification to the code; I sued this: 'namespace WinAutoComplete'

    Now, when I hit F5, I get this:

    So, I hit Build > Build Solution.  I still get the same message after VS rebuilds the project.

    Can you help me out with 2 things:

    #1)  What does this error message mean?  .exe is missing?  How do I get the .exe back?  I've seen this kind of error before; I've never figured out how to resolve it.  There must be a super-easy solution for this, right.

    #2)  Start a new project.  Copy the code from that link; paste it behind the form.  Add the appropriate objects and modify the ConnectionString.  What happens?  I'm pretty sure you'll get this message:

    The type or namespace name 'Form1' could not be found (are you missing a using directive or an assembly reference?)

    How do I resolve this issue?

    Thanks everyone!!


    Ryan Shuell

    Friday, October 12, 2012 10:07 PM
  • Ryan,

    i just did your suggested Step 2 without any problem. I created a Winform project, switched to the code window and replaced in my code anything between :

    namespace WindowsFormsApplication1
    {
    
    
    
    }

    with the code from the article between:

    namespace WinAutoComplete
    {
    
    
    
    
    }
    

    Then i have added the controls like described and it did compile without a problem.

    By the namespace problem i have meant that you should replace the "namespace WinAutoComplete" ( if you have copied this also ) with the namesapce of your project.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by ryguy72 Saturday, October 13, 2012 3:56 PM
    Saturday, October 13, 2012 8:47 AM
  • Ah!  There are 2 occurrences of 'namespace'; one behind Program.cs and one behind Form1.cs.  Ok, I changed BOTH (before I just changed the one behind the Form1.cs).  Ok, almost in business now, but for some reason or another, the Form1_Load event never fires, and thus none of the auto-complete stuff works.

     

    I got it working!!  Thanks for the puch on this.  Seems pretty simple now; I guess my mind wasn't totally engaged in the problem before.

     

     

    One thing I noticed is that the original code errors out on this line:

    comboBoxPattern.SelectedIndex = 2;

     

    I commented that out, and it worked perfect.  I wonder why that would cause an error; must be something specific to my DB.  I tried changing the number to 1 & 0; still didn't work.

     

     

    Anyway, this was a great learning experience.  Thanks again, Heslacher!!

     



    Ryan Shuell

    Saturday, October 13, 2012 3:58 PM