| By Richard K. Blum | Article Rating: |
|
| November 10, 2005 08:45 AM EST | Reads: |
17,332 |
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.
You may not even be aware that there are options for .NET developers in the Linux world. Much of the .NET work in Linux is a result of Microsoft's attempt to standardize the C# language by submitting it to the ECMA. With an international standard for .NET programming, many open source organizations are starting to look at the .NET development environment on non-Windows systems.
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
There are several different groups that are working on porting the .NET specifications to open source environments. By far the most popular .NET implementation in Linux is the Mono project.
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:
- A Common Language Infrastructure (CLI) to run .NET applications
- A .NET-compatible class library
- Class libraries to support Linux-specific functions
- A C# compiler
- Two ASP.NET Web servers
- Dozens of .NET utilities
Creating a Linux Environment
Getting started in a Linux environment can be a confusing venture. Unlike Microsoft, where the workstation and server environments are pretty much set for you, there are lots of different options available in the Linux world.
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:
- Red Hat Linux
- Fedora Core Linux
- SuSE Linux (owned by Novell)
The Live Linux CD
A great feature of Linux is the boot-able CD. This is a CD that contains a pre-installed Linux distribution. Booting your PC from the live CD automatically starts and runs Linux with little or no effort on your part!
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
If you choose to install a Linux distribution on your PC, you must manually install Mono. The Mono Web site (http://mono-project.com) contains several download options for getting the Mono package. With all of the different possibilities in the Linux world, there are lots of different installation options.
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
Once Mono is installed, it's time to test it out. The Mono package contains several different command-line utilities for working in the .NET environment. The most important for developers is mcs, the Mono C# compiler.
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
The result is 15
$
Congratulations, you just compiled and ran your first .NET program on a Linux system!
Getting Graphical
It is crucial to be able to create graphical windows applications in a .NET development environment. This is one area where Mono is still trying to catch up. Unfortunately, there have been several failed attempts in Mono to implement the System.Windows.Forms class libraries. However, it is starting to look as though there is light at the end of the tunnel.
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.
Published November 10, 2005 Reads 17,332
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Richard K. Blum
Richard Blum currently works for a large US government organization as a network and systems administrator. He is the author of C# Network Programming (2002, Sybex) and Professional Assembly Language (2005, Wrox).
![]() |
Joe Jones 11/12/05 12:02:36 PM EST | |||
David, I agree with you completely. WinForms is the key. |
||||
![]() |
David J. McKee 11/11/05 01:31:07 PM EST | |||
http://crossplatformdotnet.blogspot.com/2005/11/getting-started-in-linux... |
||||
![]() |
Owen 11/10/05 10:27:34 AM EST | |||
Gtk# _is_ Windows compatible. Just take a look at the home page: http://gtk-sharp.sourceforge.net/. Mono is a lot closer to being cross platform than Microsoft's implementation. Gtk+ also works on Windows, and that is how projects like gaim can be ported. |
||||
![]() |
LinuxWorld News Desk 11/10/05 09:55:49 AM EST | |||
Linux and Microsoft: Getting Started in Linux for the Experienced .NET Developer. 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. |
||||
![]() |
Enterprise Open Source Magazine News Desk 11/10/05 09:00:14 AM EST | |||
Linux and Microsoft: Getting Started in Linux for the Experienced .NET Developer. 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. |
||||
- Kindle 2 vs Nook
- Is Cloud Computing Like Teenage Sex?
- GovIT Expo Highlights Cloud Computing
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Cloud Computing Can Revitalize Your Career as Software Developer
- Ubuntu-based Open Source Linux Mint Tests KDE Version
- Yahoo! SVP Shelton Shugar to Discuss Innovation at Cloud Computing Expo
- Virtualization Journal "Readers' Choice Awards" Voting Is Now Open
- Einstein, Sharks and Clouds: IT Security in the Cloud
- Adobe Flex Developer Earns $100K in New York City
- Virtualization Expo Call for Papers Deadline December 15
- Amazon Web Services Database in the Cloud
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Is Cloud Computing Like Teenage Sex?
- 1st Annual GovIT Expo: Letter from the Technical Chair
- Ulitzer News: Search vs New Media
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Confessions of a Ulitzer Addict
- GovIT Expo Highlights Cloud Computing
- Twitter, Linked In, Ning and Ulitzer: Easy Personal Branding Strategy
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- The i-Technology Right Stuff
- Linux.SYS-CON.com Exclusive: Linus Discloses *Real* Fathers of Linux
- After Ubuntu, Windows Looks Increasingly Bad, Increasingly Archaic, Increasingly Unfriendly
- Linus' Top Ten SCO Barbs
- A Closer Look at Damn Small Linux
- Netscape Co-Founder's 12 Reasons for Growth of Open Source
- Introducing "Cooperative Linux" - Linux for Windows, No Less
- *POINT - COUNTERPOINT SPECIAL* What's Wrong with the Open Source Community?
- Where Are RIA Technologies Headed in 2008?
- Linux.SYS-CON.com Exclusive: What Would UserLinux Look Like?
- i-Technology Viewpoint: The New Paradigm of IT Buying
- Is Linux Desktop-Ready Yet...or Not?






























