简体   繁体   中英

Calling a Class or Method in C# using Mono

I'm having some problems calling a class or method in C# using Mono, can anyone give some help on what I'm doing wrong?

I want this piece of code:

public static void Execute(ScriptHost host)
{
    try
    {
        TesteGUI teste = new TesteGUI(); //?
        TesteGUI(); // ?
    }
    catch(Exception e)
    {
    }
    finally
    {
    }
}       

To call this piece of code:

public TesteGUI(Gtk.Window parentWindow) : base(Gtk.WindowType.Toplevel)
{
    base.Modal = false;
    base.TransientFor = parentWindow;
    base.Decorated = false;
    base.WindowPosition = WindowPosition.CenterAlways;

    this.MyBuild();

    base.KeyReleaseEvent += delegate(object o, KeyReleaseEventArgs args)
                        {
                                if (args.Event.Key == Gdk.Key.Escape)
                                {
                                    this.Destroy();
                                }
                            };
}

What is my doing wrong and how can I make it work?

Thank you

You should do it like this:

public static void Execute(ScriptHost host)
{
    try
    {
        TesteGUI teste = new TesteGUI(parentWindow); //where parentWindow is defined somewhere earlier and is of type Gtk.Window
    }
    catch(Exception e)
    {
    }
    finally
    {

    }
}   

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM