GTK# Hello World with Mono


Here’s a simple tutorial that will show you how to run a Mono GTK-Sharp application under both Mono and the .NET framework. The general documentation leaves some parts out, so here’s a concise guide to getting that first application ready. This tutorial was written using Mono 1.2.6 with Gtk# 1.0/2.10 and .NET framework 1.0/1.1/2.0.

  1. Get Mono, install with Gtk#
  2. Get, unpack in the latest .NET directory with gacutil.exe (on my system, it’s C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322) so that there is a gtkgac folder in the directory
  3. Run gtk_gac1.0.bat and gtk_gac2.0.bat
  4. Run gacutil in the .NET directory (to avoid running the Mono gacutil) like so: gacutil /l gtk-sharp. Two assemblies should appear, 1.0 and 2.10
  5. Download hellogtk.cs into your development directory.
  6. Compile with the following command: mcs -pkg:gtk-sharp-2.0 hellogtk.cs
    • To remove the console window, add the -target:winexe flag
  7. Run with (.NET) hellogtk and with (Mono) mono hellogtk.exe
  8. You’re done!

4 Responses to “GTK# Hello World with Mono”

  1. 1 Mohammed

    I followed the instructions but I keep getting this error:
    error CS2001: Source file `Files/Mono-2.0.1/lib/mono/gtk-sharp-2.0/pango-sharp.dll’ could not be found
    error CS2001: Source file `Files/Mono-2.0.1/lib/mono/gtk-sharp-2.0/atk-sharp.dll’ could not be found
    error CS2001: Source file `Files/Mono-2.0.1/lib/mono/gtk-sharp-2.0/gdk-sharp.dll’ could not be found
    error CS2001: Source file `Files/Mono-2.0.1/lib/mono/gtk-sharp-2.0/gtk-sharp.dll’ could not be found
    error CS2001: Source file `Files/Mono-2.0.1/lib/mono/gtk-sharp-2.0/glib-sharp.dll’ could not be found
    Compilation failed: 5 error(s), 0 warnings

    I guess the problem have to do with the path, but I don’t know how to fix it?

  2. 2 Mohammed

    I managed to fix it previously I installed the mono application in Program Files but now I have installed it directly to the c:

  3. 3 modulatum

    Glad you got it working, but the error message means your assembly path data is somehow wrong. Try a clean install whenever possible.

  4. 4 Dominic Amann

    Actually, this is a bug still in the Mono package. It appears to not like the space in the “Program Files” directory. Overriding the default install folder seems to be the only way to get it working properly out of the box.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: