Почему примеры Gtk работают на одном языке, а не на другомC#

Место общения программистов C#
Anonymous
Почему примеры Gtk работают на одном языке, а не на другом

Сообщение Anonymous »

Я установил Csharp и GTK (2 и 3) в Debian Stable Linux и пытаюсь запустить файл примера кода GTK, находящийся в папке /usr/share/gtk-sharp2-examples/. Этот простой файл содержит:

Код: Выделить всё

// HelloWorld.cs - GTK Window class Test implementation
//
// Author: Mike Kestner 
//
// (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;
}

}
}
Однако при запуске с помощью команды csharp я получаю следующую ошибку:

Код: Выделить всё

$ 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) ...
У меня установлены следующие версии Gtk:

Код: Выделить всё

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
Кстати, файл кода языка Cobra, использующий GTK, корректно работает в той же системе:
(Этот пример взят из: 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
В чем проблема и как ее решить?

Подробнее здесь: https://stackoverflow.com/questions/565 ... -not-other

Вернуться в «C#»