C# Application.Run(新Form1());给出错误
我有Program.cs的标准代码:C# Application.Run(新Form1());给出错误,c#,C#,我有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.
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());
}
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Windows.Forms;
名称空间cellap
{
静态类程序
{
///
///应用程序的主要入口点。
///
[状态线程]
静态void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(新Form1());
}
}
}
有人知道问题出在哪里吗?检查您的命名空间。现有的
Form1
很可能位于与cellap
不同的命名空间中。还要检查Form1.designer.cs
类 检查您的名称空间。现有的Form1
很可能位于与cellap
不同的命名空间中。还要检查Form1.designer.cs
类 当您复制表单时,是否更改了其名称空间以便Program.cs可以看到它?当您复制表单时,是否更改了其名称空间以便Program.cs可以看到它
using ProjectName.folder
然后像这样为Form1()类创建一个对象
Form1 form1 = new Form1();
Application.Run(form1);
另外,请确保您实际拥有Form1.cs
然后像这样为Form1()类创建一个对象
Form1 form1 = new Form1();
Application.Run(form1);
另外,确保你确实有一个Form1.cs你真的有一个
Form1
类吗?我在哪里可以找到?你真的有Form1
类吗?我在哪里可以找到?