Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Winforms in Mono not opening any window?

I'm trying to use Winforms for a simple application on my Mac in Mono C#, so far I've tested this code

using System;
using System.Drawing;
using System.Windows.Forms;

public class HelloWorld : Form
{
    static public void Main ()
    {
        Application.Run (new HelloWorld ());
    }

    public HelloWorld ()
    {
        Button b = new Button ();
        b.Text = "Click Me!";
        b.Click += new EventHandler (Button_Click);
        Controls.Add (b);
    }

    private void Button_Click (object sender, EventArgs e)
    {
        MessageBox.Show ("Button Clicked!");
    }
}

But no window is opening when I test it, any help? I think my question is specific to Mono.

like image 540
Duxducis Avatar asked Aug 17 '13 23:08

Duxducis


People also ask

Are WinForms still supported?

But Microsoft begs to differ. "We continue to support and innovate in Windows Forms runtime," said Microsoft's Igor Velikorossov last month in announcing what's new for WinForms in .

Does .NET core support WinForms?

NET Core and language features. Open source improvements to WPF and WinForms for . NET Core.


1 Answers

i have the same issue, running os x mavericks + mono 3.2.3 .

i built the demos from here : http://mono-project.com/Mono_Basics , the first two worked (console+gtk) but the third (dotnet) does nothing when i run it from Terminal, doesn't throw any error, i only makes cpu load, but no window is shown...

in the end , i found the solution, on the first dotnet run, it takes about 1 minute until the window shows, on the next run it's instant. when i was testing, i was killing the process after 5-10 seconds, so that's why i didn't worked for me on first try...

like image 187
George Dima Avatar answered Sep 30 '22 18:09

George Dima