2010-07-05 79 views
-1

我有Program.cs的標準代碼:Application.Run(new Form1());給錯誤

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. 我創建了一個新的項目
  2. 我導入現有的Form1的調查,並取代現有的Form1中
  3. 當我運行該應用程序,我在提到的行上得到一個錯誤:

    錯誤1無法找到類型或名稱空間名稱'Form1'(您是否缺少使用指令或程序集引用嗎?)C:\ Users \ alexluvsd anielle \ AppData \ Local \ Temporary Projects \ cellap \ Program.cs 18 33 cellap

沒有人知道問題是什麼?

+1

你真的有一個'Form1'類? – 2010-07-05 23:47:07

+0

我在哪裏可以找到? – 2010-07-05 23:48:51

回答

0
using ProjectName.folder 

然後像這樣爲Form1()類創建一個對象。

Form1 form1 = new Form1(); 
Application.Run(form1); 

此外,還要確保你確實有一個Form1.cs的

2

檢查你的命名空間。 現有的Form1很可能位於與cellap不同的名稱空間中。也請檢查Form1.designer.cs課程。

2

當您複製表單時,是否更改了名稱空間,以便Program.cs能夠真正看到它?

相關問題