Anyone porting WinForms (Mono) to .NET Core?


#1

I was looking at what it would take to get a cross-platform client GUI library built on top of .NET Core, and I believe the path of least resistance would be to port Mono’s WinForms and System.Drawing implementations.

Their WinForms draws controls using System.Drawing and has OS-specific drivers for Windowing and Eventing. System.Drawing pushes all the platform differences into a native library that it P/Invokes.

I know, I know, cross-platform GUIs are ugly, but like I said, I think this is the path of least resistance to getting client apps working on top of .NET Core. Large parts of the implementation may also have to be removed or changed to fit the smaller .NET Core profile.

Back to my original question: Is anyone already working on this or something like it?


Cross Platform GUI
#2

Mono’s Windows.Forms is not an ideal choice for a cross platform toolkit. There is already a thread elsewhere on the forums with some suggestions for alternatives.

Here are some of the problems with Mono’s winforms implementation:

  • It is built on a partial implementation of the Win32 UI programming model
  • The above means that there are limitations caused by the model and by the partiality of the implementation
  • While there have been some updates to the periphery of the API, the core has not been maintained for 6-7 years.

It is currently at best a platform to run some old code, but I would not invest a lot on it. Not unless someone is willing to put some extensive quality time in bringing it up to par.

Your best choices today include variations of “Eto.Forms”, “Xwt”, or using an MVVM model to create per-platform UIs.


#3

Is eto.form support vb.net? I’m still using mono winform to run my desktop application on Linux. I’m looking forward on the integration to Visual Studio Addin extension with ui designer for vb.net. Is this part of the eto.form roadmap?


#4

@bricelam Yes I started doing exactly that back in December as a little weekend project: https://twitter.com/akoeplinger/status/546832629010817024

It now runs a good chunk of Mono WinForms on .NET Core, but there’s of course still work left:

Code is here: https://github.com/akoeplinger/mono-winforms-netcore, the more interesting changes to Mono are here: https://github.com/akoeplinger/mono/commits/netcore-winforms-port (note that I haven’t worked on it recently as I was busy with other things)

I do agree with @migueldeicaza though, Mono’s WinForms implementation didn’t get much love in the recent years, so not sure if it has much use outside of experimental/hobby-stuff apps.


#5

Hi there!

I agree with Miguel that WinForms is not the best choice for multiplatform.

We (@plasticscm) have been developing cross-platform Mono/.NET code for years now. Server code is not a problem but for years we relied on WinForms to run on Linux/Windows/Mac and only recently we decided to rewrite the Linux and Mac GUIs using GTK and Cocoa (both on Mono). You can check some screenshots here https://www.plasticscm.com/gallery.html#mac (linux screenshots too).

Since we’ve spent quite a good amount of time on Mono cross-platform GUI code (to say the least) probably we are in a good position to share our experiences :slight_smile:


#6

Good day!

Please allow me to rephrase my question above. Is there any existing or plan for cross-platform desktop GUI designer for .NET Core that support vb.net? or it can be something like VS addins or stand-alone GUI designer.


#7

Hi @geh, yes you can use VB.NET (or even F#) with Eto.Forms. A UI designer is in the works, but not yet complete.


#8

@Curtis Thank you for the information . I’m looking forward on the progress of Eto.Forms.


#9

I’m so hoping MS to open-up XAML technologies as well.
XAML should REALLY take over WinForms, HCJ, and should become an independent UI technology.


#10

@bricelam, @migueldeicaza has provided you with the best options for cross-platform GUI. However, as a Windows only abstraction, WinApi - https://github.com/prasannavl/WinApi, now fully supports all the abstractions for windowing natively, in a high-performance manner. Would be helpful if you’d like to build your own native GUI wrappers across platform, like I prefer to. Thought its quite low-level, and meant for high-performance scenarios. It fully supports the CoreCLR. Just thought I’ll throw in the option.

Cheers :slight_smile:


#11

If WinForms is ever ported to .NET Core i guess the way to go would be:

  1. Microsoft should Open Source the Winforms code base
  2. All calls to native Win32 APIs have to be replaced / reimplemented in native .NET (for example Message Queues and Window Handling, Native UI Elements as Tabbed View) to be able to support other systems than win32

Especially the second step is non trivial as one has to re implement some really strange Win32 Window manager behaviour.

Personally is see some chance for WPF/XAML to get ported to .NET Core as it employs it´s own rendering pipeline and does not use the window manager for most of the compositing.

In the end no one should start with a WinForms app today, as WinForms has serious limitations in a lot of aspects… Like performance, high DPI displays, compositing (no real alpha blending between controls).


.NET Foundation Website | Blog | Projects | Code of Conduct