Mono is an open source platform based on the .NET Framework. Find out how to increase your options by providing a vehicle for developing on both Windows, OS X and various UNIX/Linux platforms.

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 (http://www.mono-project.com/Downloads), 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 (http://www.gotmono.com/) for excellent install troubleshooting tips.

The Mono toolset
Once you install Mono, you may utilise 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 Builderau.com.au");
} } }

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

mcsMonoDemo.cs

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.

Do you need help with .Net? Gain advice from Builder AU forums

Related links

Leave a comment

You must read and type the 6 chars within 0..9 and A..F

* indicates mandatory fields.

Log in


Sign up | Forgot your password?

  • Staff Microsoft shows off IE9 preview

    This week, highlights from Microsoft's MIX10 conference and more in the Roundup. Read more »

    -- posted by Staff

  • Chris Duckett IE9's H.264 vote killed Ogg

    In a split decision by the judges, the winner of the W3C/WHATWG video codec consensus is H.264, taking home the future of video playback on the internet while loser Ogg goes home with nothing but thoughts of what might have been. Read more »

    -- posted by Chris Duckett

  • Staff Google launches Apps Marketplace

    Google launches and app store, while Mozilla plans to re-write its open-source license. More of this week's news in the Roundup. Read more »

    -- posted by Staff

What's on?

  • Optus Deal

    Broadband + home phone + PlayStation®3 in a single package price!