Mono

I’m a C# fan. Its been on my list for a while to finally install mono on my Linux machine (running redhat 9).

Download
For the initial download, I picked up the following packages (I know, if I were 3 years younger I’d pick up the sources and compile them myself!)

  • Mono core – mono-core-1.0.6-1.ximian.6.1.i386.rpm (4.75MB)
  • Mono development – mono-devel-1.0.6-1.ximian.6.1.i386.rpm (857KB)
  • Mono Web Dev tools – xsp-1.0.6-1.ximian.6.1.i386.rpm (141KB)
  • Mono Apache module – mod_mono-1.0.6-1.ximian.6.1.i386.rpm (13KB)
  • Mono Web Services/Form support -mono-web-1.0.6-1.ximian.6.1.i386.rpm (994KB)
  • Mono data – mono-data-1.0.6-1.ximian.6.1.i386.rpm (826KB)
  • libicu international lib – libicu-2.6.2-1.rh90.dag.i386.rpm (4.57MB)Overall, pretty cool. If this works, thats about 1/2th the size of the regular .NET framework.

    Writing My First Application
    OK – so lets see if I can’t create my first mono application. Shall it be “hello world”? Lets try something a little more original (but not much)…. Keep in mind that I don’t run X on my linux box. So I’m compiling this from the command line. In my first attempt, I tried to write C# by hand. But, as anyone who has used C# will tell you, the code pretty much writes itself. Turns out, even though I have written plenty of C#, I can’t write a program that compiles without help. OK, so instead I created the following code via Microsoft’s visual studio. Took about 2 minutes to write:

    using System;
    
    namespace helloworld
    {
    ///
    /// Summary description for Class1.
    ///
    class Class1
    {
    ///
    /// The main entry point for the application.
    ///
    [STAThread]
    static void Main(string[] args)
    {
    Console.WriteLine("does this work?");
    
    DateTime start = DateTime.Now;
    for (int i=0; i

    Compiling
    Compiling turns out to be very easy, just use:

    mcs mike.cs

    Mono compiles the source and creates “mike.exe” for you. Its a little wierd to see “.exe” files on linux, but I can deal with that.
    To run the compiled executable, you now type:

    mono mike.exe

    And viola, I can see that it takes about 187ms to count to 100million on my linux machine. (The linux machine is a 1.0GHz AMD Duron).
    Comparing the same program on windows (without the debugger, of course) takes 140ms. My windows machine, however, is a 2.8GHz Pentium 4. Quite a bit faster.
    So Mono looks very promising so far! The next step is to get the Mono IDE installed. Trying to write C# code without an IDE is just not a very fun experience. In order to that, I need to get X up and running again on this box.

  • Leave a Reply

    Your email address will not be published. Required fields are marked *