The Mainstream CLI Distributions
To date, there are two mainstream implementations of the CLI, beyond Microsoft's CLR and .NET Compact Framework (see Table 2).
Table 2: Here are two important CLR implementations in addition to Microsoft's.
||Meaning in Life
||Mono (a Spanish word for Monkey, as in 'code monkey') is an open source and commercially supported distribution of .NET sponsored by Novell Corporation. Mono is targeted to run on many popular flavors of Unix/Linux, Mac OS X, Solaris, and Windows.
||Portable .NET is distributed under the GNU General Public License. As the name implies, Portable .NET intends to function on as many operating systems and architectures as possible, including many esoteric platforms such as BeOS, AIX, Xbox, and Sony PlayStation 2 (no, I'm not kidding about those last two).
Each of the CLI implementations shown in Table 2 provides a fully functionally C# compiler, numerous command line development tools, a Global Assembly Cache (GAC), sample code, a local documentation system, and dozens of assemblies that constitute the base class libraries.
Beyond implementing the core libraries defined by Partition IV of ECMA-335, Mono and Portable .NET provide MS-compatible implementations of mscorlib.dll
(among many others). In addition, the Mono distribution defines a handful of assemblies specifically targeted at Unix/Linux and Mac OS X operating systems. With this minimal background in mind, you're ready to install Mono itself.
Obtaining and Installing Mono
First, download the Mono installer
for Microsoft Windows. When the download is complete, double click the executable to begin the installation process, accepting each of the default settings.
|Figure 1. The Mono Directory Structure: Here's what directory structure looks like after you first install Mono.|
Examining Mono's Directory Structure
|Author's Note: Installing Mono will not interfere whatsoever with any existing installation of Microsoft .NET or the Visual Studio IDE.
By default, Mono installs under C:\Program Files\Mono-<version>
(at the time of this article, the latest and greatest version of Mono is 1.1.15). Beneath that root you will find a number of subdirectories (etc
) that may appear to be strangely named unless you have a background in Unix\Linux development (see Figure 1
In this article, you need only concern yourselves with the following subdirectories:
- BinContains a majority of the Mono development tools including the C# command line compilers.
- lib\mono\gacThe location of Mono's Global Assembly Cache (GAC).
Given that you run the vast majority of the Mono development tools from the command line, feel free to add the \bin
folder path to your Path
environment variable to simplify using the command-line tools.
|Figure 2. Mono Runtime Environment: The figure shows details of the Mono runtime environment.|
As a shortcut however, you may make use of the Mono command prompt which automatically recognizes each of the command line development tools. You can activate this console via the "Start | All Programs | Mono
For Windows" menu option. To test your installation, enter the following command and press the Enter key:
If all is well, you should see various details regarding the Mono runtime environment (see Figure 2
The Mono Managed Compilers
Similar to the Microsoft's CLR distribution, Mono ships with a number of managed compilers:
- mcs.exe / gmcs.exeThe C# compilers
- mbas.exe: The Mono BASIC compiler
- booc.exe: The Boo language compiler
- Ilasm.exe / ilasm2.exe: The Mono CIL compilers
While this article focuses only on the C# compilers, it is worth pointing out the role of the remaining members. Mbas.exe
, the BASIC compiler for the Mono project, is a superset of the Visual Basic .NET programming language. While this tool is currently under development, the intended goal is to bring the world of humanly-readable keywords (Inherits
, et. al.) to the world of Unix/Linux and Mac OS X (see the MonoBasic project
for more detail).
Boo is a new object-oriented statically-typed programming language for the CLI that sports a Python-based syntax. Check out http://boo.codehaus.org
for more details on the Boo programming language. Finally, as you might have guessed, ilasm.exe
are the Mono CIL compilers (the second of which supports .NET 2.0 language constructs).
Working with the C# Compilers
was the first C# compiler for the Mono project, and it's fully compatible with C# 1.1 (in fact, mcs.exe
is written in C#). Like the Microsoft C# command-line compiler (csc.exe
supports response files, a /target:
flag (to define the assembly type), an /out:
flag (to define the name of the compiled assembly), and a /reference:
flag (to update the manifest of the current assembly with external dependencies). You can view all the options of mcs.exe
using the following command.
), as the name implies, is a version of mcs.exe
that has support for .NET 2.0 specific C# language features (generics, covariance/contravariance, nullable types, partial types, etc) and references the .NET 2.0-based base class libraries. The command line options of gmcs.exe
are identical to mcs.exe
, which you can verify with the following command:
Given the presence of two C# compilers, you might naturally assume that only gmcs.exe
can be used to build .NET applications that make use of the C# 2.0 language enhancements. In reality, mcs.exe
is the first of the two compilers to support 2.0 features, which are then perfected and ported to gmcs.exe
The difference is that mcs.exe
automatically references the .NET 1.1-based base class libraries, while gmcs.exe
always references the .NET 2.0-based base class libraries. Given this, gmcs.exe
will become the default compiler in a future Mono release leaving mcs.exe
in the dust as a historical footnote.