[Mono-list] Mono, Windows Forms, and Headless operation

Edward Ned Harvey (mono) edward.harvey.mono at clevertrove.com
Fri Jan 8 16:09:07 UTC 2016


I think the advice would generally be:

1. Yes you can absolutely write a Console Application, which works perfectly cross-platform, and does not need any WinForms or X11. (Right click your solution, new project, Console Application). It's better to create a new project than to convert an existing WinForms project, unless you know all the details of what's different between the two types of projects. They launch differently, in different thread compartments, and some stuff like that - it's not as simple as merely removing the System.Windows.Forms reference. Which brings me to the second point...
2. You really should separate your business logic from the GUI code.
3. In general, you should not expect WinForms to work well on anything other than windows. If you need a GUI for other platforms, design a new one, or use a cross-platform GUI toolkit such as Eto.Forms. If you don't need a GUI... Then separate the WinForms GUI code from the non-GUI code, so you can build your non-windows project independently of WinForms.

Really, the core logic should be moved to its own assembly, so the winforms project and console project can both reference it.

There is *some* support for WinForms on non-windows platforms. Rarely does it ever work well - nobody on a mac or linux wants windows that look like WinForms - and that's if it works at all. (Lots of times it's straight up nonfunctional). Even if it works perfectly, nobody wants to be dependent on launching X11 on a mac, and it's only *sometimes* acceptable on linux.


More information about the Mono-list mailing list