I have installed Csharp and Gtk (both 2 and 3) in Debian Stable Linux and I am trying to run a gtk example code file present in folder /usr/share/gtk-sharp2-examples/ . This simple file contains:
// HelloWorld.cs - GTK Window class Test implementation
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// (c) 2001-2002 Mike Kestner
namespace GtkSamples {
using Gtk;
using Gdk;
using System;
public class HelloWorld {
public static int Main (string[] args)
{
Application.Init ();
Gtk.Window win = new Gtk.Window ("Gtk# Hello World");
win.DeleteEvent += new DeleteEventHandler (Window_Delete);
win.ShowAll ();
Application.Run ();
return 0;
}
static void Window_Delete (object obj, DeleteEventArgs args)
{
Application.Quit ();
args.RetVal = true;
}
}
}
However, on running it with command csharp, I get following error:
$ csharp HelloWorld.cs
(7,8): error CS0246: The type or namespace name `Gtk' could not be found. Are you missing an assembly reference?
(7,8): error CS0246: The type or namespace name `Gtk' could not be found. Are you missing an assembly reference?
(7,8): error CS0246: The type or namespace name `Gtk' could not be found. Are you missing an assembly reference?
(7,8): error CS0246: The type or namespace name `Gtk' could not be found. Are you missing an assembly reference?
... (many times) ...
I have following versions of Gtk installed:
Package Installed Previous Now State
=======================-===============-===============-===============-=====
gtk-sharp2 2.12.40-2 2.12.40-2 2.12.40-2 install
gtk-sharp2-examples 2.12.40-2 2.12.40-2 2.12.40-2 install
gtk-sharp2-gapi 2.12.40-2 2.12.40-2 2.12.40-2 install
gtk-sharp3 2.99.3-2+b1 2.99.3-2+b1 2.99.3-2+b1 install
gtk-sharp3-examples 2.99.3-2 2.99.3-2 2.99.3-2 install
gtk-sharp3-gapi 2.99.3-2+b1 2.99.3-2+b1 2.99.3-2+b1 install
Incidentally, a cobra language code file using Gtk runs correctly on the same system:
(This example is from: http://cobra-language.com/trac/cobra/wiki/GtkSimpleWindow )
@args -pkg:gtk-sharp-2.0 # version 3.0 also works;
use Gtk
class MyWindow inherits Window
def onDeleteEvent(obj, args as DeleteEventArgs)
"""
This method is tied to the deleteEvent, and is called when the close
button is clicked. It causes the application to quit.
"""
Application.quit
cue init(title as String)
# pass the title to the parent window
base.init(title)
# set a size for our window
.setDefaultSize(300, 200)
# register method to handle the close event
listen .deleteEvent, ref .onDeleteEvent
class MainProgram
def main
# initialise the application
Application.init
# create an instance of our main window
window = MyWindow("Cobra's First Window")
# show all the widgets within the window
window.showAll
# start running the application
Application.run
Where is the problem and how can it be solved? Thanks for your help.