0

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

1
  • 2
    You're trying to call a constructor, so you have to use the new TesteGUI way. However, you're missing a parameter - you have to pass the parent window to the constructor. Commented Mar 7, 2014 at 12:30

1 Answer 1

1

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 { } } 
Sign up to request clarification or add additional context in comments.

1 Comment

You are welcome. Please mark it as answered as well so the question does not remain in the Unanswered category. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.