7

I have built an (Windows Forms App) application on Windows in C#. Now, I would like to target this whole project / application to mac OS without changing the application. Is there any easy way to achieve it? I don't want to rebuild the entire app from scratch on MAC. I don't want to use virtual machine on MAC... I have Visual Stuido 2017 and a paired MAC. But, I'm lost here.

ThomAce
  • 301
  • 4
  • 7
  • 1
    I think your choice would be Mono, an open source implementation of .net. – Ezequiel Barbosa Nov 25 '18 at 10:35
  • If you have used the .net core framework, you can run your application on a mac, if the framework is installed there. – Philippe Nov 25 '18 at 10:36
  • I remember that back them when I used it to compile a Windows Form project on Linux, it worked but I basically had two problems, which were the inability to edit Windows forms on it (even though it ran Windows forms normally) and the necessity to deploy using MySql instead of SQL Server (but now you have SQL server for Linux) – Ezequiel Barbosa Nov 25 '18 at 10:37
  • This SO question is what you are looking for - https://stackoverflow.com/questions/22661589/porting-winforms-application-to-mac-os – Abdisamad Khalif Nov 25 '18 at 10:38
  • Also give a look at UNO Platform https://platform.uno/ – Tony Nov 25 '18 at 10:52
  • What kind of application? Console? WinForms? WPF? UWP? You didn't ask a valid question yet. – Lex Li Dec 01 '18 at 17:05

2 Answers2

3

;TLDR Mono, using WinForms and MonoDevelop IDE for development.

.NET Framework is the full implementation that includes everything but runs only on Windows.

.NET Core is the newer OpenSource implementation of .Net framework but doesn't include WPF/WinForms - because those rely heavily on DirectX/GDI essentially making them Windows only.

Xamarin. Xamarin based off of Mono framework branched more towards iOS and Android. There is a Xamarin Mac but it supports the same GTK# based UI toolkit as Mono.There is a WinForms equivalent UI toolkit as well called Xamarin Forms but it is mobile only (iOS, Android & Universal Windows Platform)

Mono. Mono is OpenSource implementation of .Net framework, uses GTK# by default for UI. Does run fine on all of Windows, Linux, macOS. Uses GTK# as underlying UI toolkit on all OSes including Windows.

What's Cross Platform? There is a subset of Base Class Library, called .NET Standard Library - as well as the compilers platform, only these subsets of .Net are truly cross-platform.

To sum it up, Mono does however support Windows Forms on both Linux & macOS. Except some corner cases it works very well. However the UI look and feel is Windows only. It is like running Windows applications under WINE. Default Mono IDE is MonoDevelop.

Xamarin Mac is great if you want to write a new application from scratch since Xamarin Mac exposes you full macOS SDK and offers its own IDE (Xamarin Studio).

In your situation though, Mono is best option. After having installed mono you can even try running your current app as mono appName from terminal. It should render the UI even if the paths and other resources are broken.

Update 2021

WPF and WinForms now are open source and part of .Net Core (which now is referred to as .Net. Core is dropped in name). The previous classic .Net is now called .Net framework. New WPF/WinForms features enhancements are on available for .Net only. Though these still are Windows only and will stay so.

Avalonia UI Framework and Uno Platform are newer .Net Core (AKA .Net) based cross-platform solutions. Both use XAML. Avalonia is more like WPF while Uno tries to be cross-platform UWP.

Abdullah Leghari
  • 2,332
  • 3
  • 24
  • 40
  • 1
    Thank you. So is that simple? I have simply downloaded Mono 32bit in to my Windows system and executed the previously compiled WinForms app. It worked pretty well. Except some visual glitches, but acceptable way. Many thanks for your feedback! – ThomAce Jan 03 '19 at 09:17
  • Several mistakes in this answer. 1) Xamarin.Mac is not based on GTK#, but native Cocoa API (as it evolved from MonoMac). 2) When you wrote this answer in 2019, Mono WinForms did not even run on macOS due to the removal of 32 bit Carbon API on new macOS releases. So at that time Mono wasn't the best option compare to .NET Core as Avalonia UI and Uno were there already. – Lex Li Mar 12 '23 at 23:39
0

You have to use .NET Core (not .NET Framework) to run app properly on different OS than Windows.

Differences between platforms explained