Take the open source development plunge with Mono

The open source Mono project brings .NET development to non-Windows systems. It allows you to develop code that is run on Windows systems, in addition to Linux, UNIX, and OS X. Learn more about Mono by installing it and taking it for a test drive.

TechRepublic's free .NET newsletter, delivered each Wednesday, contains useful tips and coding examples on topics such as Web services, ASP.NET, ADO.NET, and Visual Studio .NET. Automatically sign up today!

Mono is an open source development platform based on the .NET Framework. This platform increases your options by providing a vehicle for developing Windows applications, as well as OS X and the many flavors of UNIX/Linux.

What is Mono?

Mono is based on the fact that the C# language and the CLI (Command Language Infrastructure) have been accepted as standards by ECMA.

The Mono libraries include .NET compatibility libraries (including ADO.NET, System.Windows.Forms, and ASP.NET) and Mono-specific third-party class libraries. It's also possible to embed Mono's runtime into applications for simplified packaging and shipping. In addition, the Mono project offers an IDE, a debugger, and a documentation browser.

How to install Mono

Mono is freely available from the project's Web site, with downloads available for Linux (a generic installation, SUSE, and Red Hat), Windows, and OS X. You can download the complete source code and compile it (which is the only choice if your platform isn't supported) or download the appropriate installation package. We'll stick to the installation package route in this article.

Once you download the appropriate package for your platform, the installation process varies by operating system. Currently, I have Mono running on Windows XP and SUSE Linux 9.2 machines. The Windows installation is as simple as downloading the installation package and running it on your machine, whereas the other distributions are not as easy.

The Linux installations include individual files for the various aspects of the Mono platform. Here is a sample of the parts of Mono available for download for SUSE:

  • mono-devel-1.0.6-1.ximian.9.1.i586.rpm—Mono core package with C# compiler
  • mono-core-1.0.6-1.ximian.9.1.i586.rpm—Mono core runtime
  • mono-data-1.0.6-1.ximian.9.1.i586.rpm—Database core

Each file in the list is a RPM (Red Hat Package Manager) file. You may install these files on the Linux box with the rpm command-line tool. For example, you can install the core Mono runtime with the following command:

rpm – i mono-core-1.0.6-1.ximian.9.1.i586.rpm

After installing Mono, you should add it to your system's path so you can easily issue commands without specifying the complete path. You can do this via the Window's control panel or using the export PATH command on Linux.

Tip: If you're experiencing any Mono installation problems at this point, I recommend visiting the Got Mono? Web site for excellent install troubleshooting tips.

The Mono toolset

Once you install Mono, you may utilize its various tools. Here's a look at some of these tools:

  • mono—The mono interpreter that allows for the execution of applications without using JIT. This allows you to run applications from the command line. There is no corresponding tool in the Microsoft .NET Framework.
  • mcs—The C# compiler that accepts all the same command line options that the Microsoft C# compiler (csc.exe) does.
  • monodies—A tool that allows you to disassemble applications into IL (Intermediate Language). It provides functionality similar to Microsoft's ildasm.exe.

Please refer to the Mono documentation for a more complete list of tools, along with a discussion of each command's options.

Build a Mono application

Now we'll build a simple Mono application to see how to use a few of these tools. The following code prints a sample message to the console:

using System;
namespace Builder.Samples {
public class MonoDemo {
public static void Main(string[] args) {
Console.WriteLine("Check out TechRepublic.com");
} } }

We'll save this simple example as MonoDemo.cs, which may be compiled with Mono's C# compiler:


The result of the compilation is the file MonoDemo.exe. The .exe file extension is common on a Windows system, but it is an odd occurrence on a Linux system. Therefore, we'll run our example with this command-line interpreter:

mono MonoDemo.exe

The great aspect of this example is that we may run the compiled file on a Windows, Linux, Mac OS X, or any platform running Mono or the Windows .NET Framework. This is because the Mono compiler compiles code into an intermediary form known as IL.

The Microsoft C# compiler does the same thing. However, Mono doesn't have a complete implementation of the .NET class libraries; it does have additional Mono-specific libraries. Consequently, not all applications developed with Mono can be run in the Microsoft .NET Framework and vice versa.

You will have to take this into consideration during development by understanding the target platforms and future demands for compatibility. Likewise, you should visit the Mono site frequently to stay up-to-date with the project since new features (like class libraries) are continuously being added. This is true on the Microsoft side as well.


While I love the ability to transfer my C# knowledge from the Windows platform to the many flavors of Linux and other platforms, I am hesitant about full-blown .NET development on anything but Windows. Basically, Microsoft donated the C# language as well as the CLI to the community but other technologies like ADO.NET and ASP.NET were not submitted. This makes me wonder if Microsoft will make a move to squash the ASP.NET and ADO.NET engines currently available in Mono. Applications hosted on Web servers other than IIS and Windows hurt Microsoft's bottom line.

This may be my paranoia, but it is something I will keep an eye on. One last issue is the lack of support for non-C# languages; this leaves VB.NET programmers in the cold.

Dive in

The Mono project is an impressive feat accomplished within the open source framework. It supports many features of the .NET Framework, with 2.0 features currently supported or in the process of being supported. In addition, Mono's specific libraries for developing Linux-based applications (the gnome interface) are a boost for Linux development. Mono is a good reason for Windows developers to take a peek at Linux.