Click here to Skip to main content
16,019,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I added new form (Form3.cs) on my project with project --> add new form.

I tried to write:
C#
Form3 f3 = new Form3(); 

and underlines "Form3" and get the error:
C#
The type or namespace Form3.cs could not be found (are you missing a using directive or an assembly reference)? 

I have not deleted anything.

How to fix this?
Posted
v3
Comments
Vreeti 16-Mar-13 7:51am    
Hi... Please share the code u have written..
Also verify that the namespace of Form3 and the form in which u are calling Form3 are same or not..
Shubham Choudhary 16-Mar-13 7:51am    
where is your form !!! in a folder or else!!!
marcel zol 16-Mar-13 9:25am    
I just made a new project, add forms, wrote some code. Then i needed another form and add it, but this one i can not use it. Folder with this project contains Form3.cs, designer,...
[no name] 16-Mar-13 10:50am    
Did you try rebuilding?
marcel zol 16-Mar-13 11:21am    
Yes, i tried rebuilding. No luck.

1 solution

Hello!

I was able to replicate this kind of error message by changing the name of the namespace.

In your Form3 you have the following: namespace Aprer
C#
namespace Aprer   // This name must be the same as the namespace in Form1
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Close();
        }
    }

}


This may be the problem.

Check the namespace of the form Form1 and Form3, they must be the same.

Or you can put in Form1: Using Aprer;

Or even:
C#
Aprer.Form3 f3 = new Aper.Form3();
f3.show();
 
Share this answer
 
v2
Comments
marcel zol 16-Mar-13 18:25pm    
This was it!!! I totally forgot that i change the name of my app (long ago). And now i added new form and it had a new namespace. All of the namespaces must be the same. It works!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900