GNU/Linux and Mono
are two leaders of open source software. Debian is a Linux distribution with a social contract
that places it among the best examples of free and open source software. Mono provides an open source development platform for .NET. So what does Mono have to offer the Debian user who wants to tap .NET?
This article determines how much of the Mono 2.0 (and beyond) platform is available for Debian users by walking through how well the two products play together. It explores the Mono landscape, going over Debian packages and explaining the associate commands and relevant information about up-to-date .NET compatibility.
Mono Breakdown: Virtual Machines and Managed Code
Virtual machines and managed code are old concepts that have been revived in the past ten years or so through Java, with its Java Virtual Machine (JVM) and byte code, and then .NET, with its Common Language Runtime (CLR) and managed code. Managed code doesn't run directly on the CPU but rather on a virtual machine (VM), and the VM is an intermediate layer between the CPU and its machine code that behaves like a CPU. In effect, the VM replaces the CPU and the byte code replaces the machine code. This approach is used mainly for portability; if all compatibility issues are solved at the VM level, then the byte code programs will run on all platforms where the VM exists. All this also bears advantages in terms of security and memory management.
Programs that run on the .NET CLR are written in a language called Common Intermediate Language (CIL). As the open source implementation of the CLR, the Mono runtime also can run code written in CIL. This opens up all the CPUs and operating systems that Mono runs on to any CIL binary code produced by .NET Visual Studio compilers.
Getting Started with Mono on Debian
To start using Mono, you first install the Mono runtime, which provides the virtual execution environment to run a CIL executable. The first Debian package to install with the apt utility is mono-jit:
apt-get install mono-jit
Under /usr/bin, you now will find a Mono Linux executable that is the interpreter for CIL programs. From here on, the instructions use an "unstable" version of Debian GNU/Linux in order to download and install Mono version 2.0. Unstable is a misleading term, as it refers to a fully functional Debian release with the newest packages.
A .NET executable is an .exe file, but unlike any other .exe file, it cannot be run by itself without a CLR. With Mono, you can run it with this simple command:
Clearly, Mono is not another Windows emulator! It can run only Windows Portable Executable (PE) programs written in CIL and produced by .NET compilers.
Gendarme and Other Mono Tools
Two packages named mono-tools-devel and mono-tools-gui provide a group of useful applications that can help explain how Mono and the CLR platform are structured:
- gui-compare (quite an interesting tool)
Among these tools, gendarme deserves special consideration; it can directly inspect CIL code to discover problems that the compiler cannot identify.