Mono: .NET for Linux

Several years ago Microsoft developed a new programming language named C#. To go along with the new language, Microsoft also introduced a new technology termed CLR, Common Language Runtime, which among other features allows programs written in different languages to interact with each other much more easily than was previously possible.

The Linux community faced one small problem with the release of these new technologies: Microsoft only intended to implement each for its own operating systems. Thus, The Mono project (www.go-mono.com) was founded to implement both the C# programming language and the CLR under Linux. As an aside, Mono now also runs under Windows, making it an alternative to Microsoft's C# implementation.

The Mono project was founded by Miguel de Icaza, best known for his founding contribution to the GNOME desktop environment. de Icaza's company, Ximian (www.ximian.com), has contributed most of the resources behind Mono.

Mono consists of three key components:

MCS: the Mono Compile System is responsible for turning C# source code into bytecode and building an executable program.

Mono: the Mono runtime system is responsible for performing Just-In-Time compilation of the bytecode produced by MCS. Mono implements the environment within which your C# programs are run.

A set of Class Libraries: these implement many common features used in many C# programs, such as collection classes, mathematical functions and file I/O.

Mono is still a work in progress, so not all aspects of the C# language and the CLR are properly implemented yet. That doesn't mean Mono is useless, however. Now is a great time to get in early and start playing with the language. In my experience, Mono has successfully compiled and run all of the simple programs I have thrown at it.

If you do happen to find a bug or missing feature in Mono, this is your chance to contribute to the open source community. You can find information on filing bug reports and other ways in which you can contribute to Mono at www.go-mono.com/contributing.html.

Before you fire up your machine to file a report, be sure to take note of other reports to see what makes up a good bug report, and check to see that your bug has not already been spotted by someone else.

Installing Mono

A copy of Mono 0.26 has been included on the cover CD of the PC World November 2003 edition. As a minimum, you must compile and install both mcs-0.26.tar.gz (C# compiler & class libraries) and mono-0.26.tar.gz (CLR). You will need the development tools component of your distribution to be installed to compile Mono.

To compile on most systems, untar each archive and type the following within the directory created by each archive:

$ ./configure --prefix=/usr/local
$ make
$ make install

You will need to be logged in as the super user by using the 'su' command to perform the last command listed above. If Mono compiles properly, it will be installed under /usr/local/. If you try to run Mono and receive a "command not found" error you may need to add /usr/local/bin to your path by typing:

$ export PATH=$PATH:/usr/local/bin Hello World

Here is a quick example of a simple C# program that will work with Mono. The program uses Mono's I/O system to output "Hello World" to the screen.

Each line is numbered to aid readability, so if you type this into your computer, remove the number at the start of each line.

01 using System;
02 class HelloWorld {
03 public static void Main(String[] args) {
04   Console.WriteLine("Hello World");
05 }

Type this program into a text file and save it as "HelloWorld.cs". To compile the program, type:

$ mcs HelloWorld.cs

If the program compiles correctly you will see the message "RESULT: 0". You can now run the program by typing:

$ mono HelloWorld.exe

Documentation

There is a large effort under way to document all of the classes implemented with Mono. This work-in-progress can be viewed at http://mono.ximian.com:8080. Currently, most popular classes are very well documented, but there are large gaps in less commonly used areas.

Mono aims to implement the C# language and CLR to the same level as the specification followed by Microsoft, so books and tutorials designed for the Microsoft implementation are equally useful with Mono. Microsoft publishes a lot of helpful information via its developer network Web site at http://msdn.microsoft.com. O'Reilly & Associates publishes an extensive collection of articles for all levels covering C# and .NET at www.ondotnet.com.

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Alastair Cousins

PC World

1 Comment

Anonymous

1

Works great....

The only class I had trouble with is System.Windows.Forms.Webbrowser. This is implemented, but I was missing some native libraries to make it work.

In most cases I was able to compile applications and libraries in Windows/Visual Studio and run them directly in Linux. A few times I've had to change a a couple lines, or a config-file. But the resulting changes still ran perfectly in Windows.

The integration with IKVM makes Mono a good vendor neutral platform for C#/Java interop.

Comments are now closed.

Most Popular Reviews

Follow Us

GGG Evaluation Team

Kathy Cassidy

STYLISTIC Q702

First impression on unpacking the Q702 test unit was the solid feel and clean, minimalist styling.

Anthony Grifoni

STYLISTIC Q572

For work use, Microsoft Word and Excel programs pre-installed on the device are adequate for preparing short documents.

Steph Mundell

LIFEBOOK UH574

The Fujitsu LifeBook UH574 allowed for great mobility without being obnoxiously heavy or clunky. Its twelve hours of battery life did not disappoint.

Andrew Mitsi

STYLISTIC Q702

The screen was particularly good. It is bright and visible from most angles, however heat is an issue, particularly around the Windows button on the front, and on the back where the battery housing is located.

Simon Harriott

STYLISTIC Q702

My first impression after unboxing the Q702 is that it is a nice looking unit. Styling is somewhat minimalist but very effective. The tablet part, once detached, has a nice weight, and no buttons or switches are located in awkward or intrusive positions.

Latest News Articles

Resources

Best Deals on GoodGearGuide

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?