Porting C# Windows GUI to C# web app : how to get it work out-of-the-box for Win, Mac & Linux?

2.7k views Asked by At

I would like to rewrite an application that currently works as a Windows GUI in C#. The problem is, it works well on Windows, but is not adapted for Mac and Linux because of GUI issues with Mono.

So my idea, was to continue with C# (needed because of an essential sub program that needs to run C# and cannot be ported) and try to rewrite it as a web application that any user on Windows, Mac or Linux could access easily and make it work.

It is also important that my application remains working "out-of-the-box" because it aims high accessibility.

I've looked for solutions like :

  • KayakHTTP but it does not support POST data ! (needed for a web GUI)
  • XSP2 from Mono and make an ASP.NET MVC web app, but will it really work with my web app to make an out-of-the-box application ?

Alternatively, do you have any other idea for me to have a C# web app working out of the box for the end users ? The only thing needed would be to install Mono on Mac and Linux.

Thank you very much for your help.

EDIT 1 : I realize that I have not explained all aspects correctly. In fact, there are 2 applications in my project :

  • The CORE application which is written in C# and is too big to be ported or rewritten and thus must use Mono for running on Mac and Linux
  • My GUI application using Windows Forms which is written in C# too and controls the CORE application

My goal is to convert my GUI application into a web app application so there's no more the Windows Forms GUI hassle on Mac and Linux.

2

There are 2 answers

3
Damir Arh On BEST ANSWER

Is it necessary for your core application to run on the client?

If NOT, then the best approach is to rewrite everything as a web (ASP.NET) application which is going to run on a Windows server. Users on all your target platforms will then access this app through a web browser.

If YES, then a web app is not a good idea. You really don't want to require a web server on your clients. You have two possibilities:

  • Take a look at the GUI toolkits available for mono and select one that is available on all your target platforms to avoid having different front ends for each of your platforms.
  • To ensure best user experience on all platforms you should choose the native GUI toolkit for each of the platforms and write a different front end for them: either using Mono or using a native development environment as long as your core application has an interface that can be accessed from it (e.g. command line or similar).
0
John Saunders On

This is a duplicate question, but I don't have time to find the duplicate.

Briefly, the answer is: don't do this. You cannot translate a desktop application to a web application on a one to one basis: the two paradigms are too different.

I recommend instead refactoring your current application to remove all dependencies on the GUI. Then, write a totally new web application to meet the requirements, and have the web application call the code you refactored out of the desktop application.

Be aware of the big, hidden difference between the two platforms: the web application will be running on a server. It will be used by multiple users at the same time, and by multiple threads at the same time. While you are refactoring, be certain to note any code that would be sensitive to the difference. For instance, code that uses static member fields now could work in the desktop application because there is only one user at a time. In a web application, that static will be shared across all users and all threads.

This may not be what you had in mind.