-1

I'm just new in C# Windows Form. Now I have a project that Uploads a txt file and output into a PDF file. Now I need to use C# windows form for this but I'm just curious if I develop this using C# Windows form will I be able to install the application on a MacOS environment and use it as how I can use it on windows? Are there any consideration needed? Like do I need to install a certain package just to make it work in Mac or vice versa?

MadzQuestioning
  • 3,341
  • 8
  • 45
  • 76

1 Answers1

5

I'm just new in C# Windows Form.

Hi!

Now I have a project that Uploads a txt file and output into a PDF file.

Go on...

Now I need to use C# windows form for this

No, you don't need to use WinForms to simply upload a text file and download a PDF.

but I'm just curious if I develop this using C# Windows form will I be able to install the application on a MacOS environment and use it as how I can use it on windows?

No, you cannot. WinForms is tightly coupled to the Microsoft Windows operating-system (the biggest clue is in the name: Windows Forms. WinForms' is a thin wrapper around Windows' default windowed controls and widgets (also called User32 and Common Controls) as well as OLE, COM + ActiveX, and other Windows-centric APIs.

There are attempts to make a subset of WinForms work on other operating systems, but because WinForms is not natively cross-platform you won't have things like support for macOS's main menu and your users will be able to tell that your program doesn't look and feel like a native program.

Are there any consideration needed? Like do I need to install a certain package just to make it work in Mac or vice versa?

No, it won't work.

Alternative Approaches:

  • Make your application using WinForms System.Windows.Forms and make it available to macOS users through some form of application remoting:
    • Run it on a Windows box accessed using macOS' Remote Desktop app.
    • Run it on a Windows box accessed using a browser-based RDP gateway.
    • Run it in a Windows virtual-machine running on an Apple Mac (Parallels Fusion, VirtualBox, etc).
  • Using only natively supported cross-platform features in .NET Core:
    • Make your application with a built-in http://localhost ASP.NET web-server that hosts a GUI web-application accessed with a web-browser that interacts with the rest of your application code.
    • Make a command-line only application.
    • Make a text-mode GUI application using a library like ncurses for .NET.
  • Make a platform-specific GUI while still sharing the rest of your application code (e.g. using Xamarin to use Cocoa from .NET, use WinForms or WPF on Windows, GTK# for Linux/BSD, etc).
Dai
  • 141,631
  • 28
  • 261
  • 374
  • Might be worth noting .NET 5 will have some level of WinForms support (and will be cross platform): https://devblogs.microsoft.com/dotnet/announcing-net-5-0-preview-1/#:~:text=NET%205.%20.,that%20is%20higher%20than%20both%20. – jslowik Jul 10 '20 at 02:15
  • 3
    @jslowik The .NET 5 runtime is cross-platform, yes - but WinForms is just one component of .NET's greater class-library which is not included in the cross-platform part. That blog article doesn't say anything about WinForms being made available on other platforms - and I think it would be impossible to anyway, because things like `Control.Handle` become meaningless, for example. – Dai Jul 10 '20 at 02:23
  • Good call out, @Dai. I think I just wanted it to be true! – jslowik Jul 10 '20 at 02:27
  • @Dai thanks for the reply as a followup question will I still be able to use C# to develop an application to work both for Windows and Mac? – MadzQuestioning Jul 10 '20 at 02:30
  • @MadzQuestioning .net core is now available to develop console application both Mac & Windows too. But Winform is not, even it could be developed with .net core, but these components are not support. – Tấn Nguyên Jul 10 '20 at 02:40
  • @TấnNguyên thanks make sense now. – MadzQuestioning Jul 10 '20 at 02:43
  • @MadzQuestioning That depends if you want to make a non-browser-based GUI application using or a command-line application. Currently only command-line applications are cross-platform - but you can build a browser-based GUI using a built-in web-server using ASP.NET, for example. **You can** build a platform-specific GUI for macOS in C#/.NET though, but by using Xamarin: https://www.jenx.si/2020/01/15/how-to-start-developing-macos-applications-with-csharp/ – Dai Jul 10 '20 at 03:28
  • @MadzQuestioning I've amended my answer with a listing of alternatives. – Dai Jul 10 '20 at 03:33
  • @Dai thanks really appreciate your help will accept it as solution – MadzQuestioning Jul 10 '20 at 12:20