Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I compile a Windows.Forms application on Linux for .NET Core?

Tags:

c#

linux

winforms

I can compile my application on Linux using mono mcs, but the result is an executable for .NET Framework 4.5. On windows it runs but I cannot use any newer functionality.

I tried to find out how to compile it with .NET SDK 5.0 but on Linux it seems to not include Windows Forms.

Is there a way to compile a forms application on Linux which uses at least .NET Core 2.0?

like image 638
Martin Avatar asked Dec 07 '25 13:12

Martin


2 Answers

Windows Forms (and WPF) are both not supported on Linux with .NET Core and probably never will be. Winforms runs on mono, but that is based on .NET Framework, not .NET Core. The reason is mostly because the internal implementation of Windows Forms is actually an abstraction layer over the Windows GDI, and therefore a linux port would need to be a complete rewrite.

.NET 6.0 will bring a new GUI framework called maui, which is intended to bring real cross-platform experience to .NET. This is hopefully the last step to make .NET really cross platform, as it was actually designed 20 years ago. You can already try it out, as prerelease versions of .NET 6.0 are ready for download (go to https://aka.ms/dotnet-download).

like image 57
PMF Avatar answered Dec 09 '25 03:12

PMF


You can develop WinForms and WPF UI applications using .Net Core. But these UI applications can run only on Windows. Only non-UI applications developed in .net core is truly cross-platform and can run on Windows, Linux and Mac OS.

The MAUI framework is yet to be officially released from Microsoft that allows UI applications to be cross-platform.

MAUI

like image 31
user2377623 Avatar answered Dec 09 '25 01:12

user2377623