|
YOUR FEEDBACK
|
TOP MICROSOFT .NET LINKS Mono Getting Started in Linux for the Experienced .NET Developer
Get your applications ready for the world's fastest-growing OS
By: Richard K. Blum
Nov. 10, 2005 08:45 AM
As an experienced .Net developer, I'm sure you are comfortable creating programs in your home environment - using Visual Studio on a Windows PC. What about using other platforms? In the .NET world, not many developers think much about cross-platform development. However, with the growing popularity of Unix, and specifically Linux, as a server platform, it might be time to consider a cross-platform .NET development environment.
The trick to .NET development in Linux is to build the proper development platform. There are a few different options for creating .NET applications on Linux, and trying to put the pieces together can be complicated, especially if you are new to the Linux world. This article will help take some of the complexity out of the process, and show the first steps toward plunging into .NET in Linux.
.NET in Linux Although it does not necessarily have a good connotation in the English language, mono is derived from the Spanish word for monkey, its official mascot. The Mono package is making great strides in implementing much of the .NET framework on an open source environment. The current version of Mono (1.1.9) includes:
Creating a Linux Environment First off, if you have been looking to install Linux, you probably already know that there are literally hundreds of different Linux distributions available. A Linux distribution is a prepackaged set of Linux utilities and applications that when put together create a Linux environment. Different distributions combine different sets of utilities and applications. Your first decision is which distribution is right for your purposes (.NET development). The Mono project recommends a few different Linux distributions:
The Live Linux CD There is a Live Linux CD specifically for Mono users. The Monoppix live CD (www.monoppix.com) can be freely downloaded. This is a painless way to test-drive both Linux and Mono without having to build a PC for it.
Installing Mono The Mono project provides specific install packages for the Red Hat, SuSE, and Fedora Linux distributions. These packages install Mono on the target PC without any intervention from you. This is by far the easiest way to install Mono. If you already have a Linux distribution installed, but is not directly supported by one of the Mono installation packages, don't worry - there is still an option for you. Besides the standard install packages, Mono also has a generic binary installer program. The generic installer program installs Mono into a folder of your choice on your Linux system. This enables you to install multiple versions of Mono on the same PC. This is great for testing your software with different Mono release levels.
Using Mono Let's take a C# program to put the Mono installation through its paces. Listing 1 shows a sample C# program (SampleClass.cs) that uses two classes, one as an internal data class, and the other to support the Main method. To build the program using Mono, use the mcs compiler. From a Linux command line type:
$ mcs SampleClass.cs The compile should complete with no errors. The output of the compile is the executable program SampleClass.exe (note that the executable program maintains the Windows .exe suffix, even though it was built on a Linux platform). You can run the SampleClass.exe program on either a Linux or Windows platform. To run it on the Linux platform, you must use the Mono runtime program, mono:
$ mono SampleClass.exe 10 5 Congratulations, you just compiled and ran your first .NET program on a Linux system!
Getting Graphical Mono has started the Managed.Windows.Forms class, which implements most of the System.Windows.Forms class methods using the standard System.Drawing classes. While this may still not be the best approach, it certainly has gotten farther than any other approached tried to date. The problem with creating graphical classes in Mono is the wide variety of graphical environments in Linux. It is difficult to find a common graphical API set from which to build the .NET classes. Besides the standard System.Windows.Forms classes, Mono also includes two other classes for windows programmers: GTK# and Cocoa#. As the name implies, the Cocoa# classes are used for writing windows applications on the Mac OS X platform. These windows are 100 percent compatible with the standard Mac windows look and feel. YOUR FEEDBACK
MICROSOFT .NET LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
||||||||||||||||||||||||||||||||||||||||