C# 新创建的GTK#项目中的错误
我刚刚在32位机器上安装了Ubuntu 14.10中的C# 新创建的GTK#项目中的错误,c#,monodevelop,gtk#,ubuntu-14.10,C#,Monodevelop,Gtk#,Ubuntu 14.10,我刚刚在32位机器上安装了Ubuntu 14.10中的Monodevelop 5.7.0。我创建了一些用于测试的控制台C应用程序,一切正常。但是当我试图创建一个GTK 35;项目并执行它时,在程序和主窗口类中出现了以下3个错误: 命名空间“应用程序”中不存在类型或命名空间名称“Init” 命名空间“应用程序”中不存在类型或命名空间名称“Run” 命名空间“应用程序”中不存在类型或命名空间名称“Quit” 我一直在尝试添加一些参考资料并搜索其他解决方案,但没有成功 以下是应用程序的类别: Pr
Monodevelop 5.7.0
。我创建了一些用于测试的控制台C
应用程序,一切正常。但是当我试图创建一个GTK 35;
项目并执行它时,在程序和主窗口类中出现了以下3个错误:
命名空间“应用程序”中不存在类型或命名空间名称“Init”
命名空间“应用程序”中不存在类型或命名空间名称“Run”
命名空间“应用程序”中不存在类型或命名空间名称“Quit”
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;
}
}
我刚修好。当我错误地创建项目时,我将其命名为“02”,因此在类
Program.cs
中,默认情况下Monodevelop将其命名为“Application”,而不是项目名称,从而出现错误
必须更改类Program.cs中的命名空间“Application”:
Program.cs
using System;
using Gtk;
namespace two // for example
{
class MainClass
{
public static void Main (string[] args)
{
Application.Init ();
MainWindow win = new MainWindow ();
win.Show ();
Application.Run ();
}
}
}
为了避免这种情况,请记住不要在项目名称中仅使用数字。您可以在问题中发布相关的代码摘录吗?名称空间应用程序{}是您的还是来自MonoDevelop在创建项目时生成的样板代码?当您有一个名称与命名空间相同的类时,会出现很多问题,IDE不应该这样做。它是由MonoDevelop生成的…我的MonoDevelop版本(Gentoo上的3.0.2)使用项目名称作为
MainClass
周围命名空间的基础(在我的测试中是namespace monogtktest
)。我在任何地方都看不到命名空间应用程序。你能指定你正在运行的MonoDevelop的版本吗?哈:)Gentoo甚至没有这个不稳定的包,我必须通过一个覆盖。这意味着什么。祝你好运:)