Learn how to get the Mono beta up and running for deploying .NET applications to Linux and other platforms.
The Mono Project has to be one of the most eagerly awaited open source projects for developers, bringing the .NET framework to Linux and other platforms, opening up a range of possibilities for application deployment.
Recently, Beta3 of the Mono project was released and in this article we are going to look at how to get the beta up and running on Linux, and how to deploy your first .NET application to the Mono platform.
If you are Windows developer who is considering using Linux to host your .NET applications, the Mono beta provides a good way to test and tweak your applications before making the move.
Mono Beta 3 (like all betas) should only be used for testing purposes only and is not recommended for production use.
For this walk-through we are going to use Red Hat 9.0 as our platform to install and configure Mono. If you don't have a Red Hat or other Linux server available, you can download the Red Hat installation ISO's from here
If you don't have a spare computer or server to load RedHat, you can turn your existing machine into a dual-boot machine but it may be easier to use a virtual machine like VMWare but make sure you read through any installation notes for installing Red Hat.
Once you have Red Hat up and running, you will need to download the Mono Beta3 from the the Go-Mono Web site. There are different versions depending on the operating system you are using, including:
- Red Hat 9.0/x86
- Fedora Core 1/x86
- Fedora Core 2/x86
- SLES 8/x86
- SUSE 9/x86
- SUSE 9.1/x86
- Windows (2000 and above)
- Mac OS X
For this article we are going to download the Red Hat 9.0/x86 version.There are two different ways you can download the beta-either one large zip file with everything in it or as individual RPM files.
If you are new to Linux, RPM stands for "Red Hat Package Manager" and is a standard file format used to deploy software packages on Linux using the RPM Package Manager. You can find more information on RPM here.
The easiest way to install the Mono beta is to download the zip file that contains all of the RPM files that you need. Once you have unzipped the RPM files, you may try to install each of the individual packages by double-clicking each package to launch the installer, but there may be dependencies or other applications that need to be installed first. The easiest way to install all of the RPM files at once is from the command line.
Make sure you are logged in as the root user and then use the command line
below to install all of the packages at once:
rpm -Uvh —nodeps *.rpm
If you already jumped ahead and installed a couple of the packages or if you already had some of these packages installed, you can force the installation of all of the Mono packages using:
rpm -Uvh —nodeps —force *.rpm
Tip: For more options when using RPM at the command line, type RPM -help or visit the RPM "How-To" document here.
Once you have installed all of the RPM packages, we need to go do some testing to make sure that all of the Mono components are running. Mono has it's own light-weight Web server called XSP which was written using C# and ships with a number of test pages you can use to determine if the Mono beta is installed and working.
To start the XSP Web server, open a terminal and run:
mono /usr/bin/xsp.exe —port 80
With the Web server up and running, you can now view the test .ASPX pages that ship with the Mono beta by navigating to http://127.0.0.1/test/ where you should see the default Web page shown below:
Figure 1: Sample .ASPX pages
There are a number of sample .ASPX pages that you can use see how Mono handles different ASP.NET features, including user interface controls, code-behind and different techniques for data binding and some sample Web services and documentation.
Note: Some the samples require additional setup. For example, some of the data binding examples require a database table to be created. In most examples, the instructions will be included in the error message that is returned when you attempt to view the page.
Now that you have confirmed that Mono is installed and that the Web server is up and running, we can start testing out your own .NET applications. One of the RPM files in the zip file provided with Beta 3 contains a copy of MonoDevelop, an open source IDE that you can use to develop applications based on the Mono framework. You can find the Mono Develop icon in the program menu under Programming > More Programming Tools > MonoDevelop.
Figure 2: The MonoDevelop IDE
Once you are in the MonoDevelop IDE, you can use the import option under the File menu to import a Visual Studio project and then compile and run it from within the MonoDevelop IDE. And don't forget, Mono supports C# but not VB.NET, so make sure any apps you want to test are written in C# before attempting to port them over.
Whether you are a Linux developer who is looking for a new toolset or a .NET developer looking for a new platform, Mono Beta 3 has a little bit of something for everyone.
Discuss this in the Builder Forums
Do you have a related question or comment? You can access our C# forum from here and post your questions, reply to other users, search for answers and more.