Building Mono Applications using MonoDevelop
MonoDevelop is an IDE based on the SharpDevelop code base. However, unlike SharpDevelop, MonoDevelop was not constructed using the Windows Forms user interface toolkitit uses Gtk# instead. As you may know, Gtk# is a managed implementation of a desktop API named "Gtk+," which is quite well-known within the Unix / Linux development community. Like SharpDevelop, MonoDevelop has an impressive feature set, including:
- Support for multiple .NET programming languages
- Visual designers for Gtk# GUI applications
- The ability to import existing Microsoft Visual Studio projects
- Integration with several popular open source .NET development tools (nant, ndoc, nunit, etc)
- IntelliSense, code completion and code snippet technologies
While Gtk# itself is a platform-independent API, MonoDevelop is targeted toward people developing Mono applications on Unix/Linux distributions, given the large number of dependencies required to compile Gtk# and MonoDevelop from source. However, given that the Macintosh OS is itself Unix-based, it is possible to install this particular IDE on Mac OS X.
To do so you must install the X-Windows package as well as a slew of additional dependencies that aren't on the Mac OS X installation media. This article will not cover the (numerous) steps necessary to get MonoDevelop up and running on the Mac, however you can find detailed instructions at the MonoDevelop Web site. (A word of advice: be sure to have plenty of coffee on hand for your upcoming all night project!)
Thankfully, the Mono Linux installation package installs MonoDevelop automatically. After installing the package, you launch MonoDevelop by clicking on the MonoDevelop icon in your installation folder. After launching the IDE, you are can create a new project via the File | New project menu option.
As you would expect, you have a choice of numerous project types. Currently however, MonoDevelop does not have a native Windows Forms project template; therefore, to compile the code created from the previous SharpDevApp project, create a new empty C# project named MonoDevApp (see Figure 9).
|Figure 9. Create an Empty Project in MonoDevelop: Select a language and project type from the MonoDevelop New Solution dialog.||
|Figure 10. Compiling under Mono 2.0: In MonoDevelop, use the Project Options dialog to set the Mono runtime version you want to target.||
Now, open the Solution window (via the View menu), right click on the project icon and select the Options menu. From here, ensure you are compiling under Mono 2.0 (see Figure 10
To import your existing *.cs files into this new MonoDevelop project, right click on your project name within the Solution window and select Add | Add Files. From here, select your MainForm.cs and MainForm.Designer.cs files. Finally, right click on the References folder and add references to System.Windows.Forms.dll, System.Drawing.dll, System.dll and mscorlib.dll assemblies via the Edit References dialog box (see Figure 11).
|Figure 11. The MonoDevelop Edit References Dialog: Similar to the .NET Add References dialog, but simpler, the MonoDevelop Edit References dialog lets you select Mono reference assemblies.||
|Figure 12. The MonoDevelop Windows Forms project: The figure shows the files and references required for the demo project in MonoDevelop.||
|Figure 13. Running Under SuSe Linux: The now-familiar dialog shows the paths to the Mono GAC reference assemblies running under SuSe Linux.||
After finishing these tasks, your Solution window should look like Figure 12
At this point you can compile and run your application using the Run | Run menu option. This time, when you click the button, you'll see that you are indeed running under a Unix-based OS and are referencing assemblies form the Mono GAC (see Figure 13).
That should be enough information regarding MonoDevelop to whet your appetite. If you are interested in additional details, be sure to check out the official MonoDevelop Web site.