[Mono-list] simple question about how mono works

jmalcolm malcolm.justin at gmail.com
Tue Aug 23 22:12:45 EDT 2011


asommer wrote:
> 
> I have compiled simple application with MonoDevelop on Windows.
> I later has created package for Linux.
> But I will not work on Linux if I just click it.
> Is it mean that I should install also Mono on that Linux machine and start
> this application only from Mono?
> How is it works?
> Thanks!
> 

Yes, you will need Mono or .NET on any machine where you would like your
program to run.

Much like Java, .NET and Mono programs are compiled to for a kind of
hypothetical virtual machine (commonly called the CLR or Common Language
Runtime). They are not native Linux applications. They are not really native
Windows applications either although Windows is configured to make it seem
more like they are.

To run a Mono program you need to invoke an instance of this virtual machine
(contained in mono.exe) and pass it your program. For example, you might
type 'mono program.exe' where 'program.exe' is the name of your program. It
is common on Linux to wrap your program in a shell script which does this
for you so that you can do things like click on your program from the GUI
and the like.

The same thing is happening on Windows except that the Windows program
loader has been written so that it understands how to recognize if an EXE
file contains native Windows instructions (Win32 or Win64) or if it contains
.NET instructions (CIL). If the loader sees a .NET app it loads the .NET
runtime (the virtual machine) for you.

The .NET runtime has to be installed on Windows just like Mono has to be
installed on Linux. Newer Windows machines will have .NET installed already
but older ones might not. For example, Windows XP did not ship with .NET
installed although most XP machines will have it installed by now. The major
Linux distributions ship with Mono so the situation is not so different.

There is no reason that Linux could not be made to work like Windows and
load Mono for you. I have never seen this done though. In fact, it seems
common that the Linux loader is configured to assume that EXE files are
native Windows files to launch something like WINE to handle them. This of
course does not work if the EXE is actually a .NET/Mono program.

The upside of the fact that .NET/Mono programs are not native to either
Linux or Windows is that the exact same compiled program (the EXE) will run
unmodified on Linux or Windows. In fact, it will run anywhere that the .NET
or Mono runtime (the CLR) has been implemented.

--
View this message in context: http://mono.1490590.n4.nabble.com/simple-question-about-how-mono-works-tp3762443p3764331.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list