Comments
Matt McLarty wrote: For more info... Follow me on Twitter See our website
Cloud Expo on Google News

SYS-CON.TV
Cloud Expo & Virtualization 2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Cloud Computing & Enterprise IT: Cost & Operational Benefits
How and Why is a Flexible IT Infrastructure the Key To the Future?
Click For 2008 West
Event Webcasts
Getting Started in Linux for the Experienced .NET Developer
Get your applications ready for the world's fastest-growing OS

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
These are all of the pieces you need to compile and run C# .NET applications in Linux. Now all you need is a Linux platform on which to install Mono.

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)
Both SuSE and Fedora are available as supported commercial packages, and unsupported free downloads. If you are just dabbling in Linux, you can freely download the SuSE and Fedora installation CDs and try them out with Mono.

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.

About 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).

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

David,

I agree with you completely. WinForms is the key.

http://crossplatformdotnet.blogspot.com/2005/11/getting-started-in-linux...

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.

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.

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.


Your Feedback
Joe Jones wrote: David, I agree with you completely. WinForms is the key.
Owen wrote: 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 wrote: 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 wrote: 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.
Latest Cloud Developer Stories
Cloud computing is creating the new Wall Street boom, according to NIA. The only industry that is as bright as cloud computing on Wall Street is social networking, NIA said in a recent report. 2012 will be known as the year cloud computing became widely adopted worldwide. Cloud ...
Whatever your course, meet Cloud complexity head on with a unified approach to handle extreme performance, reliability, availability, and simplicity. In her session at the 10th International Cloud Expo, Ayalla Goldschmidt, Senior Director of Product Marketing at Oracle, will re...
As a Bronze Sponsor of Cloud Expo New York, Appcore is offering special passes to SYS-CON's 10th International Cloud Expo, which will take place on June 11–14, 2012, at the Javits Center in New York City, New York. Appcore manufactures the business of cloud computing. Appcore de...
Assuming you haven’t spent the last couple of years living under a rock, you’re bound to have been bombarded with all sorts of propaganda about “The Cloud.” “The Cloud,” according to the marketing types, is the greatest thing since the invention of bread, surely able to solve all...
According to a 2011 survey by the Independent Oracle User Group, over 50% of Oracle’s customers have deployed or are considering deploying private clouds. Most private clouds today support non-production workloads because enterprises are unable to deploy mission-critical applicat...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers
ADS BY GOOGLE

Breaking Cloud Computing News
Wyse Technology, the global leader in cloud client computing, today announced that the Wyse P20 PCoI...