1

I deleted default Form1 from my project and added another Windows Form as MyForm().How to set this to run as application. In fact I replaced

Application.Run(new Form()) 

to

Application.Run(new MyForm()) 

But its giving the following error:

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

4
  • 2
    What error is it giving? Commented Dec 9, 2010 at 9:47
  • Show the code of the MyForm class, then it should be easily solvable :) Commented Dec 9, 2010 at 9:50
  • Error 1 The type or namespace name 'MyForm' could not be found (are you missing a using directive or an assembly reference?)....Is any other way to this? Commented Dec 9, 2010 at 9:50
  • MyForm is defined inside a namespace. In the program.cs file, make sure that you have added using <namespace>; at the top. Commented Dec 9, 2010 at 9:57

2 Answers 2

3

Check the namespace of your new form and ensure that the application has it as a using directive.

The error means that the application class can't find the MyForm class, either because you didn't add the right assembly reference to the project (which could happen if the form is in another project), or because the form is in a different namespace (which could happen if you put it in another directory).

Sign up to request clarification or add additional context in comments.

3 Comments

am really sorry..actually I created one folder and added Form to that...there I dint changed namespace...
@Sisya - You didn't intentionally, but Visual Studio adds the folder name to the default namespace that gets created when the source file gets added. You can either remove the directory name from the namespace of MyForm, or add the namespace to the application directory. Any what are you being sorry about?
That's a bit inaccurate. It's not the application class that can't find MyForm, it's the compiler. The Application class won't be looking for anything until Sisya manages to reach runtime...
0

Providing that MyForm is a form located somewhere in your project or referenced then hover over MyForm() and press shift + alt + f10 , this should allow you to resolve the namespace :-)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.