Mono: A branch to other platforms
Continuing from where we left off
In my last tutorial, we got a basic understanding of Mono and even checked if a existing .net application would run on Mono. Now its time to get Mono running on our development machine.
To start off, go to http://www.mono-project.com and click download Mono. Select Windows and click Mono and GTK#. Once that downloaded, run the installation.
Click next until you get to this screen.
Those are all of the files required for the best experience developing in Mono. I'm gonna explain everything in this screen shot. GTK+ is a library used by GNOME, one of the main desktop environments in Linux. GTK# is a C# wrapper to use GTK+ in your applications. I do not know what Monodoc is unfortunately. Gecko# is another c# wrapper, which allows you to access Gecko, Mozilla Firefox's layout engine. I also do not know what XSP is but I'm sure we will find out as we go. Click next until the installation starts.
This installation may take a while so as we wait, lets talk about a IDE that can develop applications under Mono. There are two IDE I know of that compile under that platform. They are SharpDevelop and MonoDevelop. SharpDevelop is a c# IDE that started when .net started and MonoDevelop is a software fork thats developed under mono in c#. But now, they don't seem to be related to each other because they have when there separate ways. MonoDevelop isn't currently running on Windows yet, but SharpDevelop is so head over to http://www.sharpdevelop.net and download SharpDevelop.
Once we have Mono and SharpDevelop installed. We can install the Mono AddIn for SharpDevelop. The AddIn is attached to this article, so just download it to your desktop.
Go to your SharpDevelop's installation directory and navigate to the AddIns folder. Create a folder called samples and in that, create a folder called Mono.AddIn. Remember that zip we just download? Extract that into the Mono.AddIn folder and it should look like this:
Creating a Hello World Application
The moment we've been waiting for! Your first Mono application. Lets get started by opening SharpDevelop and click new solution. Click C# and in that, click Mono and in that click GTK# application.
Lets name it MonoHelloWorld. After you create the project, it should show up like this:
Before we dive into coding, we need to tell SharpDevelop to run our app under Mono. So go to Projects > Project Options > Debug. Your settings should look like this:
The start external program option should be *monoinstallation directory here*\bin\mono.exe. And the other options should be what you see in the picture. Now switch back to you Mainwindow.cs and click Debug (the green arrow). Thats is a GTK# application. The downside to this is, you have a lot of new classes to learn. But if you loads of free time, then this will be easy.
After a quick modification to the code, it should be like this.
Now, finally, click Debug (green arrow) and it will run our new Mono Application. And it should look like this:
If you don't prefer hand-coding a UI (using a designer) , then you should get Linux or Mac and get MonoDevelop. Otherwise, you can wait till it gets ported to Windows, or do it the hard way. What ever way you choose.
To conclude this tutorial, I'm gonna summarize what we have learned. We have installed Mono on our Development Machine. We have Installed and Configured SharpDevelop to compile on Mono. We have coded a simple Mono applications running on GTK#. Well, that pretty much sums it up. We have did a lot in this tutorial and even lost about 700mbs of Hard Disk space. In the next tutorial, we will get into advanced coding in GTK# and even take a look at Glade# another UI library in Mono.
This artcle can be downloaded as PDF from here.
And the Mono.AddIn.zip can be downloaded here.
This post has been edited by Amrykid: 18 May 2009 - 06:09 PM