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.

Join the newsletter!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Alastair Cousins

PC World
Show Comments

Cool Tech

SanDisk MicroSDXC™ for Nintendo® Switch™

Learn more >

Breitling Superocean Heritage Chronographe 44

Learn more >

Toys for Boys

Family Friendly

Panasonic 4K UHD Blu-Ray Player and Full HD Recorder with Netflix - UBT1GL-K

Learn more >

Stocking Stuffer

Razer DeathAdder Expert Ergonomic Gaming Mouse

Learn more >

Christmas Gift Guide

Click for more ›

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Walid Mikhael

Brother QL-820NWB Professional Label Printer

It’s easy to set up, it’s compact and quiet when printing and to top if off, the print quality is excellent. This is hands down the best printer I’ve used for printing labels.

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Ratchada Dunn

Sharp PN-40TC1 Huddle Board

The Huddle Board’s built in program; Sharp Touch Viewing software allows us to easily manipulate and edit our documents (jpegs and PDFs) all at the same time on the dashboard.

George Khoury

Sharp PN-40TC1 Huddle Board

The biggest perks for me would be that it comes with easy to use and comprehensive programs that make the collaboration process a whole lot more intuitive and organic

David Coyle

Brother PocketJet PJ-773 A4 Portable Thermal Printer

I rate the printer as a 5 out of 5 stars as it has been able to fit seamlessly into my busy and mobile lifestyle.

Featured Content

Product Launch Showcase

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?