I just installed Monodevelop 5.7.0
in Ubuntu 14.10 in a 32bit machine. I created some console C#
applications for testing and everything works fine. But when I tried to create a GTK#
project and execute it, I have the following 3 errors in the Program and MainWindow classes:
the type or namespace name 'Init' does not exist in the namespace 'Application'
the type or namespace name 'Run' does not exist in the namespace 'Application'
the type or namespace name 'Quit' does not exist in the namespace 'Application'
I've been trying to add some references and searching for other solutions but with no luck.
These are the classes of the application:
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;
}
}
I just fixed it. When I created the project erroneously I named it "02", so in the class Program.cs
, by default Monodevelop named it "Application" instead of the project name, making the errors appear.
You must change the namespace "Application" in the class Program.cs:
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 ();
}
}
}
To avoid this remember do not use just numbers in the name of your projects.