[英]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.