As far as I know, both Wine and Mono are used to run Windows applications under Ubuntu.
So I was wondering
- what their differences are? Are they both virtual machines? Or does each belong to some other category?
- It is better When to use which for what kinds of Windows applications? For example, those applications that may or may not require .net Framework.
- Do they depend on each other? Are they required to install together? Or does each work independently without existence of the other?
Thanks and regards!
Successfully running a program requires that three things match:
You can increase the chance of matching all three by having emulators/interpreters (for other CPU instruction sets), by having extra file loaders (for foreign file-formats), and having additional programming libraries providing more APIs.
Note also, that some processors can natively execute more than one instruction set; a PC quite often has x86 and amd64 instruction sets; an ARM processor can execute four: ARM32/Thumb/Java bytecode/ThumbEE. Some operating systems can provide more than one API natively too (Microsoft Windows provides Win32 and POSIX).
For everything else you need extra software. For running Java programs you need the three parts listed above to make it work: a Java Virtual Machine program to run the bytecode; a way of launching Java programs, and a Java Classlibrary for the programs to call. "Java" is a brandname here for several separate technologies originally developed by Sun, but to a user they are often downloaded as one.
The same applies for ".Net", which is a marketing brandname for several different technologies originally developed by Microsoft: The Common Language Run-time/Base Class Library (CLR) are the API; VES is the loader and Common Language Interface (CLI) is the instruction set.
You don't have to download those technologies from Microsoft, from Sun, or from Intel just because they originally invented something. AMD make processors compatible with Intel's standards; both Apache ("Harmony") and Google ("Android Dalvik") both make a Java-like suite; and Mono provides a CLR/CLI/VES suite. The important thing is that everyone uses the same standards, making them compatible. A DVD disc will play on any DVD player that meets the standard, and an HTML webpage will rendering in any Web Browser meeting the HTML standards.
So Mono makes CLR .exe applications run, and Wine makes Win32 .exe applications run. The only thing in common is that the filenames end in ".exe"; the contents are completely different and incompatible, so you need the right one.
Just like a Python interpreter will error when presented with Perl (and vis versa), a CLR interpreter will error when presented with x86+Win32, or JVM+Java bytecode. If you can post a link to the particular program that you're wanting to run, myself or somebody else should be able to tell you the exact instruction set, file format and API it was designed for, and what you need to install on Linux to run it. Hope that helps!
(Sometimes you might even need both. For example, the Openbve train simulator is C# and compiled to PE/COFF+CLI+CLR, but can optionally use C binary plugins compiled for PE/COFF+Win32+x86. In this case, you need a Win32 version of Mono under Wine. If the CPU architecture is also, different that would need emulating; so Mono under Wine under Qemu).
The short answer:
.NET is Microsoft's answer to Java, and Mono is an open source implementation of it. Wine is for native exes and has nothing to do with Mono except that you can maybe run the .NET runtime with it, like any other native Windows software.
The long answer:
To understand the difference between Wine and Mono(and .NET) you must understand the difference between native machine code executables and "common language runtime" aka "virtual machine" executables:
Native machine code executables use instruction codes specific to your processor and are directly executed by it. That means they have to be recompiled for different processors. Wine is able to run native machine code executables for Windows by directly running this executable code and catching any library calls it makes, redirecting them to it's own implementation of the Win32 API.
"CLR" or "VM" executables are not specific to one processor: They need an extra piece of software to enable the processor to run them. Mono/.NET is one such example of this kind of system. .NET programs need the .NET runtime installed even when you run them on Windows. Java works the same way.
So:
1) the difference between Wine and Mono: Wine is for running native machine code executables made for Windows, and Mono is for running Mono/.NET executables which are not necessarily made for any specific platform. Installing Mono on Linux is equivalent to installing the .NET runtime on Windows.
2) If the program you want to run does not use .NET at all, you must use Wine. Mono won't help you at all here.
However, if the program does use .NET you have two options, either of which may or may not work:
You can try to run it using Mono. This will fail if the .NET program also uses native functions from the win32 API, which many (but not all) .NET applications made for Windows do.
Alternatively, you can install the Microsoft .NET runtime for windows inside Wine, and then run the .NET application through it. You won't be using Mono at all in this case.
3) Wine and Mono do not depend on each other at all, but as stated above, you can use the Microsoft .NET runtime in Wine to run Mono/.NET applications.