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());
}
}
}
- i created a new project
- i imported an existing form1 into it and replaced the existing form1
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\Progra开发者_StackOverflow中文版m.cs 18 33 cellap
does anyone know what the problem is?
Check your namespace. The existing Form1
is more than likely in a different namespace than cellap
. Check the Form1.designer.cs
class too.
When you copied the Form did you change it's namespace so the Program.cs can actually see it?
using ProjectName.folder
Then create an object for the Form1() class like this.
Form1 form1 = new Form1();
Application.Run(form1);
Also, make sure you actually have a Form1.cs
精彩评论