tags:

views:

1036

answers:

6
+8  Q: 

How does Mono work

I am a developer who has used C# in Visual Studio with .net, and i have played around a little with Mono on openSUSE Linux, but i don't really understand how it works. If i write an app in Windows on .net, how does this relate to Mono? I can't just execute an a Windows .exe file on Linux without Wine, so it doesn't help me execute apps developed in Windows. Is the purpose purely to have a .net library equivalent on Linux ( and others ) to make cross platform development easier? For example, if i was a business and wanted to reach Linux customers, but really wanted to use .net, then mono should be my choice? Or is there something more that i'm missing?

+8  A: 

You can in fact run a .NET .exe file with Mono on Linux. This does not require Wine. In fact, Mono compiles programs to .exe files, which can run either with Mono on Linux or as an executable on Windows.

Greg Hewgill
+13  A: 

A Windows EXE contains multiple "parts". Simplified, the .net Code (=MSIL) is only a Part of the EXE, and there is also a "real" native Windows Part inside the EXE that serves as some sort of launcher for the .net Framework which then executes the MSIL.

Mono will just take the MSIL and execute it, ignoring the native Windows Launcher stuff.

Again, this is a simplified overview.

Edit: I fear my understanding of the deep depp details is not good enough for really much detail (I know roughly what a PE Header is, but not really the details), but i found these links helpful:

NET Assembly Structure – Part II

.NET Foundations - .NET assembly structure

Michael Stum
any chance for a slightly more detailed version? :)
DavidG
I fear my understanding of the deep depp details is not good enough for that (I know roughly what a PE Header is, but not really the details), but i found these links helpful: http://is.gd/4n4i http://is.gd/4n4n
Michael Stum
+2  A: 

Mono is an open-source implementation of Microsofts .NET CLR (Common Language Runtime). This is what runs part of .NET programs which are not in native code but in CIL (Common Intermediate Language), a language and machine-neutral intermediate language. The Runtime takes that intermediate code and translates it into machine code.

At the current state of Mono, you can take .NET programs that use the main parts of .NET (mscorlib.dll) and run them everywhere Mono runs, not just Windows.

Quantenmechaniker
+2  A: 

But as it is mentioned that Mono is open source and you can't just rely that it will be the full .NET implementation, it has some controls that are not working, you must be also careful with P/Invokes that your application will use, for e.g your application will communicate with MCI (Multimedia Controller Interface) under win32. But I was using mono writing GTK# Applications also, but I've also used my Windows applications that worked without any recompilation as mentioned our fellow programmers above, that is, mono is an open source alternative of Microsoft's .NET, and by default if you are building either WinForms or Gtk# applications mono will compile and will create an .exe assembly for each file, and of course if you want it will create an Dynamic Link Library (DLL), almost as it is done in .NET. Just for suggestion try writing some Gtk# (with MonoDevelop IDE which has its built-in gui designer called stetic). And of course mono can be a great replacement for Web Services that you can create them on .NET and you can host them on Apache (because Linux hosting nowadays are more cheap than Windows ones) web services and other asp.net apps will work under apache with a mod_mono module that must be included in apache.

A little bit out of topic but I just wanted to tell you a sneak-peek from my experience.

milot
A: 

To further Michael's response, I believe you will have to http://ask.metafilter.com/41038/Compiling-a-NET-program-with-Mono">recompile on Mono for the app to run on the Mono runtime. Exceptions may exist. I've only played around with Mono just a bit, and I've always re-compiled the source. I've never tried to run a .NET app directly on Mono.

Also, Mono 1.9 is supposed to be fully .NET 2.0 compliant. Mono Olive and Moonlight are supposed to add .NET 3.0 (less WPF) and Silverlight functionality.

Ryan Riley
+1  A: 

Also you can take a look to MoMA (if your goal is to port applications from Win to Lin).

The Mono Migration Analyzer (MoMA) tool helps you identify issues you may have when porting your .Net application to Mono. It helps pinpoint platform specific calls (P/Invoke) and areas that are not yet supported by the Mono project.

MoMA

Here is a webapp that compares the types of the BCL already implemented by Mono and the .NET Framework 3.5

http://mono.ximian.com/class-status/2.0-vs-3.5/index.html

jaircazarin-old-account