[英]monodevelop compling error; why does misses assembly reference if those exists?
我從MonoDevelop創建了一個GTK#2.0項目,它生成了兩個文件:
Program.cs
using System;
using Gtk;
namespace Application
{
class MainClass
{
public static void Main(string[] args)
{
Application.Init();
MainWindow win = new MainWindow();
win.Show();
Application.Run();
}
}
}
MainWindow.cs:
using System;
using Gtk;
public partial class MainWindow : Gtk.Window
{
public MainWindow() : base(Gtk.WindowType.Toplevel)
{
Build();
}
protected void OnDeleteEvent(object sender, DeleteEventArgs a)
{
Application.Quit();
a.RetVal = true;
}
}
我按下了“調試”按鈕,未修改任何代碼。 然后編譯器打印此:
The type or namespace name `Init' does not exist in the namespace `Application'. Are you missing an assembly reference? (CS0234)
The type or namespace name `Run' does not exist in the namespace `Application'. Are you missing an assembly reference? (CS0234)
The type or namespace name `Quit' does not exist in the namespace `Application'. Are you missing an assembly reference? (CS0234)
我在“解決方案”選項卡上看到了“參考”列表,並且存在Gtk.Application.Init,Run,Quit。 那為什么會發生這個錯誤呢?
將Program.cs修改為:
using System;
using Gtk;
namespace Application
{
class MainClass
{
public static void Main(string[] args)
{
Gtk.Application.Init();
MainWindow win = new MainWindow();
win.Show();
Gtk.Application.Run();
}
}
}
修改MainWindow.cs為:
using System;
using Gtk;
public partial class MainWindow : Gtk.Window
{
public MainWindow() : base(Gtk.WindowType.Toplevel)
{
Build();
}
protected void OnDeleteEvent(object sender, DeleteEventArgs a)
{
Gtk.Application.Quit();
a.RetVal = true;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.