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 PC World 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

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Matthew Stivala

HP OfficeJet 250 Mobile Printer

The HP OfficeJet 250 Mobile Printer is a great device that fits perfectly into my fast paced and mobile lifestyle. My first impression of the printer itself was how incredibly compact and sleek the device was.

Armand Abogado

HP OfficeJet 250 Mobile Printer

Wireless printing from my iPhone was also a handy feature, the whole experience was quick and seamless with no setup requirements - accessed through the default iOS printing menu options.

Azadeh Williams

HP OfficeJet Pro 8730

A smarter way to print for busy small business owners, combining speedy printing with scanning and copying, making it easier to produce high quality documents and images at a touch of a button.

Andrew Grant

HP OfficeJet Pro 8730

I've had a multifunction printer in the office going on 10 years now. It was a neat bit of kit back in the day -- print, copy, scan, fax -- when printing over WiFi felt a bit like magic. It’s seen better days though and an upgrade’s well overdue. This HP OfficeJet Pro 8730 looks like it ticks all the same boxes: print, copy, scan, and fax. (Really? Does anyone fax anything any more? I guess it's good to know the facility’s there, just in case.) Printing over WiFi is more-or- less standard these days.

Ed Dawson

HP OfficeJet Pro 8730

As a freelance writer who is always on the go, I like my technology to be both efficient and effective so I can do my job well. The HP OfficeJet Pro 8730 Inkjet Printer ticks all the boxes in terms of form factor, performance and user interface.

Michael Hargreaves

Windows 10 for Business / Dell XPS 13

I’d happily recommend this touchscreen laptop and Windows 10 as a great way to get serious work done at a desk or on the road.

Featured Content

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?