4

I have an application written on top of .Net framework 4.5 and C# using Visual Studio 2015 Community. I created it in Win10 OS in 64 bit machine.

Is there any possibilities to run this application in Ubuntu? Then how can I compile the application to make it compatible for ubuntu machine?

I would like to deploy it as a cross-platform application but I have a hard time figuring out the best way. I heard about Mono but I am not yet familliar with the IDE.

Please help.

Shift 'n Tab
  • 8,808
  • 12
  • 73
  • 117
  • 1
    I think it's impossible, becouse WinForms is a wrapper over WinAPI functions, which may have no analog in Ubuntu. – Anton Aug 23 '16 at 08:29
  • That's bad to hear, but i found winforms application created in **Mono** and they say that it can also run in ubuntu. My problem for this approach is i dont know how to compile my application in Mono to work in ubuntu. – Shift 'n Tab Aug 23 '16 at 08:32
  • I have found this [link]http://www.mono-project.com/docs/gui/winforms – Anton Aug 23 '16 at 08:40
  • 2
    So I was wrong, it's possible – Anton Aug 23 '16 at 08:42
  • But it refers that you can create a winforms application using Mono but i dont want to start from the beginning. The biggest of my problem encounter is how can i compile my application to make it compatible for ubuntu. tsk – Shift 'n Tab Aug 23 '16 at 08:47
  • You can create a branch for ubunty [lin]http://www.mono-project.com/docs/gui/winforms/porting-winforms-applications/ – Anton Aug 23 '16 at 08:50
  • But it make take a long time to do – Anton Aug 23 '16 at 08:51
  • You'd better switch to GTK#, xwt, or any other Linux focus approach. WinForms on Mono on Linux is far from complete and it will bite you often. – Lex Li Aug 23 '16 at 09:45
  • can we _Wine_ for that ?? – Aju Aug 23 '16 at 10:02
  • @LexLi you mean i need to start from the beginning? – Shift 'n Tab Aug 23 '16 at 10:04
  • @Aju we tried the wine, but when we run the setup.exe it shows some error: Contact vendor..., Im using ClickOne to publish it. What is your suggestion? Do we need to directly wine the .exe file of the app released? thanks – Shift 'n Tab Aug 23 '16 at 10:06
  • @Shift N' Tab sorry i don't know .Few days before I read about Wine,that's why i asked so. I didn't tried it yet.. – Aju Aug 23 '16 at 10:14
  • @ShiftN'Tab yes I mean it. – Lex Li Aug 23 '16 at 10:18
  • @Aju just fine, but we will try to wine the .exe file and not the setup maybe this will work. – Shift 'n Tab Aug 23 '16 at 12:51
  • @LexLi It is cross-platform even though i created it on windows environment? – Shift 'n Tab Aug 23 '16 at 12:51

2 Answers2

4

Unless you're using special .NET classes or native libraries it should be possible and easy.

Since the .NET compiled executables are built on bytecode, they aren't linked to a specific platform and Mono has been designed with this in mind.

Supposing you've just tested an application named "WindowsApplication", try to follow these steps:

Check under your Visual Studio projects folder, try to locate your WindowsApplication.exe. Check "C:\Users\YourName\Documents\Visual Studio\Projects\WindowsApplication\WindowsApplication\bin\Debug (or Release)

After installing Mono on your Ubuntu system check if the mono command is available in your folder (for this test just use your home dir):

username@locahost ~ $ mono --version Mono JIT compiler version 5.0.1 (Visual Studio built mono) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: normal SIGSEGV: normal (more output)

Copy your program executable from Windows into the Ubuntu folder, let's suppose you copied to the directory where you just tested mono.

Launch it by typing: mono ./WindowsApplication1.exe (if it's in your current directory) or mono /<another_path_to_your_executable>/WindowsAppliction.exe

In case it didn't run you can download the "Mono Migration Analyzer" (MoMA), which is a tool specifically designed to identify unresolved dependencies and help you solve the problem.

ManuelJE
  • 496
  • 6
  • 15
2

Re. WinForms: In theory this is possible, though you probably want to check the status of the WinForms project to see how cross-platform this is and whether certain tooling such as the forms designer is available and/or stable. If you were starting from scratch you could use GTK# instead which is cross-platform and has good tooling support in MonoDevelop/Xamarin, but that may not be helpful if you've already invested heavily in WinForms.

Re. compiling for Linux: You shouldn't need to re-compile using Mono unless you are making use of any .NET CLR specific features in your code (which naturally wouldn't be implemented in Mono) or you are using e.g. ILMerge in your build process. I'd throw your exe on Linux with the dependencies and test it to find out. If you do end up needing to recompile you can do this on Linux, BSD or Mac OS X using the Mono compilers directly or open the project in MonoDevelop and build it that way; any of these platforms should produce a program that is executable on any other *nix with Mono.

muszeo
  • 2,312
  • 9
  • 13
  • Yea this is true, i think i really need to start from head to toe since there is a big bite when converting winforms .net to cross-platform application, i used many P/Invoke method which **MoMa** detect that is not found in Mono/Xamarin IDE. – Shift 'n Tab Aug 30 '16 at 03:56