3
votes

I am completely new to Mono and Gtk#. I'm developing an app on Linux but I want to run it on Windows as well. However, if I build the app using MonoDevelop and then run the .exe file in Windows, it doesn't launch.

Is it really possible to make Windows apps using Linux/Mono, or am I missing something?

2
You must compile it for Windows. When you compile a C# project, on any OS, it will be compiled to run on the OS that compiled it. --This explains why your .exe doesn't work on Windows when compiled on LinuxSymon
@Symon just want to add, you can run .net windows compiled .exes on linux with mono. In my opinion most of the time, the dependencies will make some problems and some special parts of .net like Http* But in generell I absolutly agree with youDavid
Both the first comment and the accepted answer are wrong. C# is multiplatform thanks to the mono project, and now the .NET core. Your app does not launch because you need to install Gtk# for Windows, available in the mono project download page: mono-project.com/download/stable/#download-winBaltasarq
Your app will not be portable if you have included calls to the Win32 API. Use a tool like MoMA in order to get your exe analyzed and locate incompatibility problems. While MoMA is not 100% updated, is a very useful asset.Baltasarq
I started to maintain MonoDevelop Windows installer, so next time you might compile/debug your code on Windows so as to identify what might be wrong with it, github.com/lextm/monodevelop-windows/issues/1Lex Li

2 Answers

0
votes

Like Symon said, you have to build your project on the operating system you're intending it to be be compiled for because of the resources (API's etc.) that specific operating system is loaded with.

When I have a problem like this, I simply use a virtual machine software like VirtualBox or VMware to run Windows and then install and run MonoDevelop inside of Windows. Don't worry about the expensive cost of Windows, for you can just get Windows from Microsoft's website here. There will be a little watermark in the corner of the screen because you didn't pay for the copy, but everything is still totally legal and fit for software development.

UPDATE: A better method to do this is to install the GTK# dependencies and then recompile the program.

0
votes

Baltasarq is correct. The reason that your app won't run is that the dependent GTK# binaries are not on your target machine. The compiled .exe will run on any .NET implementation so long as it is of at least the .NET version that your executable targets and the dependent assemblies are available.