![](/img/trans.png)
[英]CallbackOnCollectedDelegate at Application.Run(new Form1())
[英]Application.Run(new Form1()); giving error
我有 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 找不到類型或命名空間名稱“Form1”(您是否缺少 using 指令或程序集引用?)C:\\Users\\alexluvsdanielle\\AppData\\Local\\Temporary Projects\\cellap\\Program.cs 18 33 cellap
有誰知道問題是什么?
檢查您的命名空間。 現有的Form1
很可能位於與cellap
不同的命名空間中。 檢查Form1.designer.cs
類。
當您復制 Form 時,您是否更改了它的命名空間,以便 Program.cs 可以實際看到它?
using ProjectName.folder
然后像這樣為 Form1() 類創建一個對象。
Form1 form1 = new Form1();
Application.Run(form1);
另外,請確保您確實有一個 Form1.cs
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.