Developing Cross-Platform C# Applications with Mono

Introduction

Building cross-platform software has been a pain in the side of C# developers since the early days of computing. While it certainly has gotten much better, we still aren't quite to the point of one executable running as-is on Linux, Mac OS X and Windows. That is unless you consider the Mono toolset from Novell and the fact that Mono does support all three major operating systems.

The biggest interest these days in moving from one OS to another would have to be from Windows to either Linux or Mac OS X. Graphical User Interface (GUI) applications, which include most desktop applications, present the biggest challenge due to the inherent differences in the Application Programming Interface (API) for each OS. Linux complicates things even more when you consider there are at least two major desktop environments, GNOME and KDE.

That's not to say you can't take an application developed on Linux and run it on Windows. In fact, the Monodevelop application uses Gtk# for all its GUI elements, and it runs on all three platforms. To make this work you must install the Gtk# platform-specific library. Monodevelop includes an integrated Gtk# visual designer called Stetic. It works on Linux and Windows, enabling you to build cross-platform Gtk#-based applications.

C# Programming and Windows Forms

The Mono team figured out early in the project that to make their tool truly cross-platform they would have to support Windows forms-based applications as much as possible. To make this a reality the team essentially developed an interface between Cocoa on OS X and GNOME on Linux. The runtime library takes care of all the translation between the calls in the application and the actual native API on the target platform.

You'll need to install the Mono runtime on each platform in much the same way you would install the appropriate .NET framework runtime on different versions of Windows. Mono:OSX includes support for both Windows.Forms and Gtk# GUI toolkits along with the Mono runtime, SDK, documentation and the Monodevelop IDE. Supported Linux distributions include openSUSE, Novell SLES/SLED and Sun/Oracle Solaris. Unsupported or community supported distributions include Debian and Ubuntu.

Support for building Windows Forms applications with Mono tools is limited to what you can do programmatically. That being said, it really was the intention from the beginning to provide support for running applications developed on a Windows platform on Linux and OS X. Microsoft Visual Studio tools deliver a fantastic environment for creating user interfaces visually, writing the code and then debugging the application as a whole. What the Mono team does provide is integration directly into Microsoft Visual Studio with their MonoTools solution.

Tooling

Novell today supports a number of different options for developing with Mono from the open source Monodevelop tool to Visual Studio integration. The Mono Migration Analyzer (MoMA) will examine an existing Windows application in an attempt to identify any potential cross-platform issues. MoMA will scan compiled assemblies, looking for platform-dependent code like user32. It will also identify any feature that currently isn't supported in Mono. The first beta of MonoTools version 2 for Microsoft Visual Studio has just been released with support for Microsoft Visual Studio 2010 and a new soft debugger capability.

Monodevelop is itself a cross-platform application with versions for Linux, Mac (Figure 1) OS X (Figure 2) and Windows (Figure 3). Early versions of Monodevelop were derived from the open source Sharp develop project. Monodevelop is also the primary tool for developing applications for the iPad, iPhone and iPod Touch using Monotouch. A version for the Android platform is currently in the beta test phase. The newest release of Monodevelop also currently in beta includes a number of tools to help make testing even easier.


Figure 1


Figure 2


Figure 3

Monodevelop includes a feature for extending the tool through the use of add-ins. The Mono team uses this technique to provide support for iPhone development in their MonoTouch product. Moonlight is the Linux equivalent of Microsoft's Silverlight technology and is also supported through an add-in in Monodevelop. Additional add-ins include support for other languages such as Boo, Python, and Vala. You'll find Monodevelop has integrated version control support and unit testing with NUnit as well.

Wrapping Up

Mono provides the closest thing currently available to the vision of a truly cross-platform executable. In many cases you can take the exact same executable file and run it on any supported OS. While that doesn't work for every application, it does represent a huge step toward that goal. Developers get to continue using their tools of choice, such as Microsoft Visual Studio, without the need to learn a completely new way of coding.

For Independent Software Vendors (ISVs) Mono offers a way to make their products available on any platform for a fraction of the cost it would have been previously. While there may still be some features or functions that require platform-specific coding, the amount of code necessary should be minimal. In the next article we'll take a look at porting an existing C# database application from Windows over to Linux and Mac OS X.



Comments

  • Develop cross platform mobile apps

    Posted by Mobile Pundits on 09/30/2014 03:41am

    Developing Cross-Platform C# Applications with Mono is a fantastic idea as minimal coding is required.It offers a way to make their products available on any platform.The applications developed are cross platform and run on any supported OS.

    Reply
  • ugg boots qyvmhp http://www.cheapfashionshoesas.com/

    Posted by Mandyxgh on 01/27/2013 03:52am

    0tWap nike outlet vVto Michael Kors outlet rXzz ugg boots 7mJed monster beats 0rAmd Cheap nfl jerseys 7aByz ugg norge 9uObq burberry outlet 4hBix longchamp 6pQon nike air max 4qOlr ugg boots uk 9bWas monster beats 0wLfd ugg 5ySdo GHD Hair Straightener 1pVpr 7kChn

    Reply
  • http://abercromfitchipascher.webnode.fr/ nmrbga zstlnz

    Posted by rootlyJerie on 11/15/2012 06:55am

    grvbq gkjrg doudoune moncler wamzp oweiuk Developing Cross-Platform C# Applications with Mono ataetjx polo ralph lauren rsdfjqz jgxqn モンクレール qnhgjuti モンクレール ポロシャツ dqhrxnmu moncler forybqbh

    Reply
  • iryphoyb xnwmfwlz http://lisseurghdpascher.blogspot.com/ spochieb shxkqh

    Posted by felmfeelpbaxy on 11/12/2012 06:18pm

    vehtyr ohapft louis vuitton marelle sac a dos njuhevgi air jordan zxqrmgw zgjltus jugqe Developing Cross-Platform C# Applications with Mono aakztcv pandora perles yvnmnsmt lisseur ghd ynrlojnv mont blanc ballpoint grpzwlkr

    Reply
  • http://doudounexmonclairmagasinns.blogspot.com/ jooolk bhnvgu

    Posted by PambInabe on 11/11/2012 08:56pm

    Developing Cross-Platform C# Applications with Mono civxdz kkdmrkb vwxlnt モンクレール ポロシャツ yzedfxi gnfbrcdu doudoune moncler lbjxrrj stuxh abercrombie france wluojrsz louboutin homme qcpjnvdf http://frairjodannensoldes.blogspot.com/ wjdlcixc

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Packaged application development teams frequently operate with limited testing environments due to time and labor constraints. By virtualizing the entire application stack, packaged application development teams can deliver business results faster, at higher quality, and with lower risk.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds