C# Question

Application.Run(new Form1()); giving error

i have the standard code for Program.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace cellap
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}



  1. i created a new project

  2. i imported an existing form1 into it and replaced the existing form1

  3. when i run the app, i get an error on the mentioned line:

    Error 1 The type or namespace name 'Form1' could not be found (are you missing a using directive or an assembly reference?) C:\Users\alexluvsdanielle\AppData\Local\Temporary Projects\cellap\Program.cs 18 33 cellap



does anyone know what the problem is?

Answer

Check your namespace. The existing Form1 is more than likely in a different namespace than cellap. Check the Form1.designer.cs class too.