Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Application.Run(新Form1());给出错误_C# - Fatal编程技术网

C# Application.Run(新Form1());给出错误

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.

我有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());
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Windows.Forms;
名称空间cellap
{
静态类程序
{
/// 
///应用程序的主要入口点。
/// 
[状态线程]
静态void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(新Form1());
}
}
}
  • 我创建了一个新项目
  • 我将现有的form1导入其中并替换了现有的form1
  • 当我运行应用程序时,我在上面提到的行中得到一个错误:

    错误1找不到类型或命名空间名称“Form1”(是否缺少using指令或程序集引用?)


  • 有人知道问题出在哪里吗?

    检查您的命名空间。现有的
    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
    类吗?我在哪里可以找到?