[Mono-list] Need Help: Mono under Windows-problems in using events

Marc Glenn mjamon at ntsp.nec.co.jp
Mon Oct 15 00:15:19 EDT 2007

Hello guys,

    I tried compiling a csharp code that uses gtk# and event handlers 
under Mono.

    // 04-gtk/01-basics
    using System;
    using Gtk;
    class MainClass {
        public static void Main (string[] args)
            Application.Init ();
            Window w = new Window ("Gtk# Basics");
            Button b = new Button ("Hit me");
            w.DeleteEvent += new DeleteEventHandler (Window_Delete);
            b.Clicked += new EventHandler (Button_Clicked);
            // initialize the GUI
            w.Add (b);
            w.SetDefaultSize (200, 100);
            w.ShowAll ();
            Application.Run ();
        static void Window_Delete (object o,
            DeleteEventArgs args)
            Application.Quit ();
            args.RetVal = true;
        static void Button_Clicked (object o, EventArgs
            System.Console.WriteLine ("Hello, World!");

    The program prints a "Hello World" on the Console after clicking the 
button "Hit Me".

    I executed it under Fedora Core 6 using the latest version of Mono 
compiler and it operates perfectly.
    But when I try to run it under Mono-Windows(latest version) and 
click the button "Hit Me", the program crashes.
    I have tried to comment out these lines
                   w.DeleteEvent += new DeleteEventHandler (Window_Delete);
                   b.Clicked += new EventHandler (Button_Clicked);
    and when I click the button "Hit Me", the program does not crash 

    Does this mean that Mono have problems with csharp events or I just 
have a wrong configuration of my Mono-Runtime..

    Need help..

    Thanks in advance

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20071015/17d814eb/attachment.html 

More information about the Mono-list mailing list