Click here to Skip to main content
14,355,756 members

HelloMono - Mono on Windows XP

Rate this:
4.37 (25 votes)
Please Sign up or sign in to vote.
4.37 (25 votes)
6 May 2004BSD
The Monkey on XP

Mono in Windows XP


If you think that you have to have Visual Studio .NET in order to develop in .NET, you are in for a pleasant surprise. Mono - in Spanish the word means monkey, in geek-speak it means choice. Either way, it is most assuredly a good thing. Mono is an open source, free implementation of the .NET Framework. On May 4, 2004, the Mono project released the first public beta of their work.

A few days after I completed my previous article - hello, world - a primitive view of the state of the art, the Mono Beta 1 was released, and I wanted so badly to include a HelloMono example in my article. The only problem was that I absolutely couldn't get Mono to work on my system. Now, I am about as tech savvy as they come. I run Windows XP, Windows 2000, Solaris 10 (Software Express), Libranet, FreeBSD, and Whitebox (basically Redhat Enterprise), and occasionally a half dozen other OSes, all on the same box. When in Windows, I have Cygwin with XFree86 available and in constant use. I thought Mono would be a breeze to setup, after all it has a windows installer. Not so, I am afraid. However, all hope is not lost - it is a few days later and I have figured out how to make Mono purr, and it runs fine. Thanks to the open source community, I was able to add a bug report to the project and while the bug is still open, some kind soul posted a reasonable workaround that got me up and running.

First, here is what got me started on the whole hello, world kick again after all of these years. Kernighan and Ritchie's ubiquitous "The C Programming Language" is considered by many to be the most influential programming book of our time. Written in 1978, it immortalized the now well known phrase - "hello, world". The book states that "hello, world" is the basic hurdle to learning all languages: "to leap over it you have to be able to create the program text somewhere, compile it successfully, load it, run it, and find out where your output went. With these mechanical details mastered, everything else is comparatively easy."

You need to have some perspective to truly appreciate this statement or you might be tempted to consider it overreaching. Dennis Ritchie designed the C programming language and it was the C language that made portability possible for the Unix operating system. Unix and Linux, Minix, BSD, OSX, YouNameItOS and even Windows owe a great debt of gratitude to the language. Even the language C# is a derivative of Ritchie's C. So when in his book, it says that "hello, world" is important, we should listen.

So it is that I have taken my inspiration from K&R's work. I can think of no better method to expose the foundations of the development environment even in the year 2004 than the old, "hello, world" approach.

This article is a "hello, world" tutorial for Mono running on Windows XP:


A basic understanding of .NET, the command-line, and working in Windows is assumed. Here are some good resources to help you get up to speed on these topics:

There are basically three required pieces to doing .NET development using Mono on Windows XP:

  1. Windows XP (Otherwise it wouldn't be Mono on Windows XP :) ).

  2. Mono

    More information is available at:

    Install Mono:

    • Download and install Mono using the Windows Installer
    • Create a monoenv.bat file in the Windows directory or somewhere else on the Path (not required, but it will make your life much easier)
      @echo off
      set MONO_PATH=d:\mono\lib
      set PATH=d:\mono\bin;d:\mono\lib;d:\ikvm\bin;d:\windows;<BR>d:\j2sdk1.4.2_03\bin
      echo mono environment established
    • Open a command prompt to test the installation
      mono environment established
      error CS2008: No files to compile were specified
      Compilation failed: 1 error(s), 0 warnings

      If the testing fails because of a System Assembly not found error - Using Explorer find all .dll files in the mono\lib\mono\gac directory and below and copy them to mono\lib

    • run mono, should print help
      Usage is: mono [options] assembly
      Runtime and JIT debugging:
          --compile METHOD       Just compile METHOD in assembly
          --ncompile N           Number of times to compile METHOD<BR>                           (default: 1)
          --regression           Runs the regression test contained <BR>                           in the assembly
  3. UltraEdit

    Well, ok, it is not a requirement, but it will sure make things easier. Get it at If you do not have a decent text editor, Notepad will work ok.

You should now be set up to develop with the Mono on the command-line.


This is a very simple tutorial and does not pretend to exercise Mono to its fullest.

OK, let's get started. What are the goals? Borrowing directly from Kernighan and Ritchie, these will be our goals for this tutorial:

  • Create the program text
  • Compile the program
  • Load the program
  • Run the program
  • Locate the Output

Create the program text

In order to create the program text, you will need to use a text editor of some sort. I prefer using UltraEdit, although Textpad or Notepad will work as well. Do not even bother with Word or Wordpad, these are arguably word processors and they tend to do funny things to text files. Fire up the editor and you will be ready to begin.

Here is K&R's "hello, world" C program in all its splendor, it is the model I am replicating, so I feel it is fitting to include it here:

// reader Ryan Beesley noticed that the original quote lacked an include <BR>// needed to compile so I added the following include - it is not part <BR>// of the original K&R hello, world program
#include "stdio.h"

  printf("hello, world\n");

The C#.NET code that is required to print "hello, world" to the console is similarly simple:

1  using System;
3  namespace mynamespace {
4    public class HelloWorld {
5      public static void Main(string [] args) {
6        Console.WriteLine("hello, world");
7      }
8    }
9  }

Line 1 This is a using directive that tells the compiler that we will be referencing objects that are included in the System namespace. According to Microsoft, "The System namespace contains fundamental classes and base classes that define commonly-used value and reference data types, events and event handlers, interfaces, attributes, and processing exceptions." For our purposes, the System namespace provides the handy, dandy Console object that will allow us to print "hello, world" to the console.

Line 2 This is an empty line :) White-space, space, tab, carriage return, etc. in code (not strings) is generally considered insignificant, I tend to think of white-space as condensing to a single space or blank line.

Line 3 This is a namespace directive that tells the compiler to segregate our code in its own namespace semantically. This is not really required here, but it is good form. If you put any classes that you create in your own namespace, you will not be bitten by namespace collisions down the road. A namespace collision is what happens when there exist two semantic elements that have the same name. For instance, let's say that I create a class called Car and somewhere else within the same project someone else also creates a Car class. If I include both classes in my project, their names will collide unless they are in their own namespaces.

Line 4 This is the class declaration, our class is publicly accessible and is called HelloWorld

Line 5 The Main method. Console applications are required to have a Main method. The Main method is the method that will be executed by the operating system when the program is loaded and run. Main is public and static, it does not return anything and it takes an array of strings as arguments. static basically means that the method can be called without instantiating a HelloWorld object. The arguments are include by convention, we will not be passing in any arguments.

Line 6 "hello, world" gets printed by this call to the Console object's WriteLine method which writes the argument to the console followed by a carriage return.

Line 7 End of the Main method.

Line 8 End of the HelloWorld class definition

Line 9 End of the namespace

Save the file to your hard drive as HelloMono.cs and open a command prompt.

Compile the program

Compile the application using the Mono C# compiler:

mcs HelloMono.cs

This should produce output similar to the following, without error.

Compilation succeeded

Compiling the application will generate an executable named HelloMono.exe

Load and run the program

Loading and running the program are accomplished in a single step.

Load and run the application from the command-line by typing:
mono HelloMono.exe

Locate the Output

Console output is incredibly easy to find. Generally, it appears on the line immediately following the command itself. Running the program should produce the following output:

hello, world

Congratulations, you have completed the HelloMono tutorial. Now I know what some of you are thinking, "It took nine lines to produce the same output K&R did in four? Ha! Gotcha, I knew .NET was lame." Well, it is not that simple. Here is a minimalist C#.NET HelloWorld console example for the purist:

1  class HelloWorld {
2    public static void Main(string [] args) {
3      System.Console.WriteLine("hello, world");
4    }
5  }

It is still bigger than the K&R version, but not by much.


That's it, really - not radically different than the same example using the .NET Framework. Give Mono a shot, it is worth a little investment of time to have a choice.

Email the author Will Senn


Kernighan, B.,& Ritchie, D. (1978). The C Programming Language (pp. 5-6). New Jersey, Prentice-Hall.


Background Resources

General Resources


Version 1.0
This is the first version of this article.


This article, along with any associated source code and files, is licensed under The BSD License


About the Author

Will Senn
Founder Emporia State University
United States United States
Will Currently serves as Assistant Professor of Information Systems and Data Analytics. Previously he led research, development and product delivery efforts on a global scale. He has a long career as a software architect and developer and enjoys programming in any language on any platform for any good purpose.

Comments and Discussions

GeneralRe: Go Mono on Solaris Pin
thawes12-May-04 11:13
memberthawes12-May-04 11:13 
GeneralRe: Go Mono on Solaris Pin
thawes12-May-04 11:25
memberthawes12-May-04 11:25 
GeneralRe: Go Mono on Solaris Pin
Anonymous31-May-05 1:41
memberAnonymous31-May-05 1:41 
GeneralRe: Go Mono on Solaris Pin
Huaiyang Mao1-Aug-05 2:31
memberHuaiyang Mao1-Aug-05 2:31 
GeneralRe: Go Mono on Solaris Pin
thawes11-Aug-05 17:24
memberthawes11-Aug-05 17:24 
QuestionIs Mono the ONLY free implementation of .NET? Pin
Will Senn8-May-04 3:59
professionalWill Senn8-May-04 3:59 
AnswerRe: Is Mono the ONLY free implementation of .NET? Pin
MyBlindy13-May-04 11:08
memberMyBlindy13-May-04 11:08 
GeneralRe: Is Mono the ONLY free implementation of .NET? Pin
Will Senn13-May-04 11:22
professionalWill Senn13-May-04 11:22 

I'm not wrong - it is a replacement - it works fine, of course that's not it's only function as you so correctly point out.

Maybe you aren't replying to me, because I stated that it was OPEN-SOURCE and free.

GeneralRe: Is Mono the ONLY free implementation of .NET? Pin
MyBlindy13-May-04 15:44
memberMyBlindy13-May-04 15:44 
GeneralRe: Is Mono the ONLY free implementation of .NET? Pin
Will Senn13-May-04 17:01
professionalWill Senn13-May-04 17:01 
GeneralRe: Is Mono the ONLY free implementation of .NET? Pin
MyBlindy14-May-04 7:14
memberMyBlindy14-May-04 7:14 
AnswerRe: Is Mono the ONLY free implementation of .NET? Pin
reflog22-Aug-04 8:05
memberreflog22-Aug-04 8:05 
AnswerRe: Is Mono the ONLY free implementation of .NET? Pin
Ivan Deras13-Dec-04 20:43
sussIvan Deras13-Dec-04 20:43 
AnswerRe: Is Mono the ONLY free implementation of .NET? Pin
Anonymous8-Feb-05 4:44
memberAnonymous8-Feb-05 4:44 
GeneralMono Pin
Marc Clifton7-May-04 17:51
protectorMarc Clifton7-May-04 17:51 
GeneralRe: Mono Pin
Colin Angus Mackay8-May-04 1:35
memberColin Angus Mackay8-May-04 1:35 
GeneralRe: Mono Pin
Marc Clifton8-May-04 3:35
protectorMarc Clifton8-May-04 3:35 
GeneralRe: Mono Pin
Will Senn8-May-04 3:49
professionalWill Senn8-May-04 3:49 
GeneralMono and MyXaml? Pin
Marc Clifton8-May-04 4:25
protectorMarc Clifton8-May-04 4:25 
GeneralRe: Mono and MyXaml? Pin
Will Senn8-May-04 6:42
professionalWill Senn8-May-04 6:42 
GeneralRe: Mono and MyXaml? Pin
Marc Clifton10-May-04 8:32
protectorMarc Clifton10-May-04 8:32 
GeneralRe: Mono and MyXaml? Pin
Will Senn10-May-04 14:35
professionalWill Senn10-May-04 14:35 
GeneralRe: Mono Pin
Colin Angus Mackay8-May-04 7:32
memberColin Angus Mackay8-May-04 7:32 
GeneralCool Pin
Judah Gabriel Himango7-May-04 11:11
memberJudah Gabriel Himango7-May-04 11:11 
GeneralRe: Cool Pin
Will Senn7-May-04 11:18
professionalWill Senn7-May-04 11:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 6 May 2004


41 bookmarked