Channels ▼
RSS

.NET

.NET Development on Linux

Source Code Accompanies This Article. Download It Now.


Eric has developed everything from data reduction software for particle bombardment experiments to software for travel agencies. He can be contacted at EricTerrell@comcast.net.


Although I started my software-development career as a UNIX programmer, for the past 20 or so years, I've worked primarily in the Windows world. However, I recently started wondering about the quality and usability of Linux distributions. I was also curious about developing C# .NET programs in Linux using Mono (www.mono-project.com), a Linux implementation of the .NET Framework. In addition to Linux, Mono (which is sponsored by Novell) lets you develop and run .NET client and server applications on Solaris, Mac OS X, Windows, and UNIX.

When I installed Ubuntu Linux (www.ubuntu.com) in a Virtual Machine (VM) on my Windows machine, I found that Ubuntu was a user-friendly and attractive OS. And while .NET development is far from perfect on the Linux platform, it is certainly possible to develop C# .NET desktop programs for Linux, and the development tools are easy enough to use that they're actually fun. In this article, I walk you through the process of installing Ubuntu in a VM, and get you started writing .NET desktop applications for Linux.

Installing VMware and Ubuntu

While it's certainly possible to install Linux on a dedicated partition on your Windows machine, it's much more convenient to install it in a VM. VMware (www.vmware.com) offers two free desktop virtualization products—the lightweight Player and more feature-rich Server. Player and Server can run Linux VMs, but only Server can create them. (You can download VMware Server 1.0.6 from www.vmware.com/download/server, but you need serial numbers from VMware. That's quick and easy.)

The following instructions cover creating a new VM and installing the OS and development tools. If you prefer to use the VM that I created, it's available online; see www.ddj.com/code/. After downloading the VM, boot it in Server, log in as user "user" with password "password," and skip to "The Sample Application" section of this article. If you're building your own VMs, download Ubuntu 8.0.4 LTS Desktop Edition (www.ubuntu.com/getubuntu/download), choose Standard Personal Computer (x86, 32-bit), and download ubuntu-8.04.1-desktop-i386.iso.

Launch Server and connect to the Local host. Click New Virtual Machine and choose Typical VM configuration. For the Guest Operating System, Select Linux and Ubuntu. In the Network Type step, specify network address translation (NAT). If you don't have Internet connectivity when you boot Ubuntu, you may need to change this option. Specify a Disk size of 10 GB, and check "Allocate all disk space now." After Server creates the virtual disk, click "Edit virtual machine settings." Select the Hardware tab and click Add. Add a Sound Adapter and choose "Use default sound adapter." Then add a USB Controller so that you can transfer files between the host and guest OS with a flash drive. The default 512 MB of RAM is sufficient, but set the number of CPUs to 2 if you have at least a dual-core machine. Select the CD-ROM device and choose "Use ISO image," and point the drive to the Ubuntu ISO file you downloaded. After you've installed Ubuntu, change this setting to "Use physical drive."

Click "Start this virtual machine" and the VM boots from the Ubuntu virtual install CD. When the Ubuntu installer loads, select your language, and pick "Install Ubuntu." Don't worry about the warning message about VMware Tools, you'll install them later. Click Forward to advance through the Install wizard. Choose the default disk-partitioning scheme. Specify a user name and password. On Step 7, click Install.

Log on when the installation completes. On the Ubuntu desktop, go to Preferences/Screen Resolution to increase the screen to a comfortable size. Enable automatic logins by going to System/Administration/Login Window. Select the Security tab and enable automatic login for the user you created. Now install VMware Tools, which will enable you to copy and paste text between the host and guest operating systems. On the VMware VM menu select Install VMware Tools. After the file browser launches, go to Accessories/Terminal. The "Terminal" is really a command shell. Enter the following commands:


$ sudo -i
# cd /tmp
/tmp# tar zxpf /cdrom/V*.gz
# cd vmware-tools-distrib
# ./vmware-install.pl


The sudo command grants the command shell the higher (root) privileges required to install software. The other commands unpack and install the software. After the install completes, set up VMware tools as a startup program. Go to System/Preferences/Sessions. In the Startup Programs tab click Add. In the Command textbox specify /usr/bin/vmware-toolbox --minimize.

Now it's time to install the development tools. Go to System/Administration and launch the Synaptic Package Manager. This utility downloads, installs, updates, and removes software packages. Click the Search toolbar button and search for "mono." Select the packages:



mono-debugger
monodevelop
monodoc
monodoc-base
monodoc-browser
monodoc-gtk2.0-manual
monodoc-http
monodoc-manual
mono-gmcs

and select Mark for Installation. When you've selected and marked them all, click the Apply toolbar button.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Comments:

Video