Comparing the Free .NET Implementations Mono and Dotgnu LOTS of DOTS

Comparing the Free .NET Implementations Mono and Dotgnu LOTS of DOTS

PROGRAMMING Mono and DotGNU Comparing the free .NET implementations Mono and DotGNU LOTS OF DOTS The Open Source projects Mono and DotGNU open Microsoft’s .NET platform to Linux developers. This article investigates how well-suited these alternative implementations are for building simple GUI applica- tions. BY MICHAEL TSCHATER n 2002, Microsoft launched a new support has prompted two projects to gram written on Windows. This short system for platform-independent de- step into the gap: Novell’s sponsored example has all the major GUI elements, Ivelopment that they dubbed .NET Mono project [1] and the open source see Figure 1. The source code is avail- (pronounced “Dotnet”). The .NET pro- DotGNU [2] project. Both Mono and able on the Linux Magazine website at ject aims to simplify the development of DotGNU are aiming to provide as com- [3]. The only functionality this code ac- network and Internet applications. It plete an implementation of the .NET tually provides is that it logs user input supports object oriented programming platform as possible. The goal of both in a window specially designed for that and comes with a unique class library projects is to allow developers to ex- purpose. suitable for use with multiple program- change software across operating system ming languages, such as C# and VB boundaries. The Original by Microsoft .NET for example. In the course of Besides basic functionality such as One way of obtaining the original Micro- launching .NET, Microsoft has discontin- string manipulation, most projects need soft .NET is the free .NET runtime envi- ued support for its previous favorite, the widgets for graphical user interfaces to ronment and SDK (Software Develop- MFC library for Visual C++. All future help them cope with day-to-day tasks. ment Kit) download. The download Microsoft products will be based on the Microsoft offers the System.Windows. gives you all the command line tools new technology. Forms library for this purpose. The needed for software development on library has GUI objects, such as Main- Windows, just like the Java SDK. The csc Free .NET? Menu, ToolBar, Combobox, or Button. command compiles an application. The Despite the platform-independent ap- Listing 1 has a short code snippet as an results can be executed directly on Win- proach of the .NET framework, Micro- example. dows. soft is highly unlikely to release a Linux To compare the Mono and DotGNU The Integrated Developer Environ- implementation, and this lack of Linux implementations, we will be using a pro- ment (IDE) Visual Studio .NET is a com- 72 ISSUE 61 DECEMBER 2005 WWW.LINUX - MAGAZINE.COM Mono and DotGNU PROGRAMMING Figure 1: The demo application includes all major GUI elements from Figure 2: Visual Studio .NET displaying the code from the sample the .NET System.Windows.Forms library. This figure shows the Win- project described in this article. The code in the figure draws graphi- dows version. cal elements. mercial alternative for .NET develop- speed. Mono uses GTK# (which is also programmers to update documentation ment that includes a debugger and dia- available for Windows) for graphical online from the Mono repository, is an- log editor (Figure 2). This package auto- user interfaces. GTK# is based on other useful feature. Besides distribution matically installs the .NET SDK. The free GTK+, which forms the basis of the specific binaries, there is an executable Sharpdevelop developer environment [4] Gnome Desktop on Linux. installer, which sets up all the required is an excellent alternative to the Visual packages. Studio .NET package. Sharpdevelop GUI with Windows.Forms After you download the 50MByte gives you a powerful IDE that only lacks The System.Windows.Forms library is package, a wizard walks you through the an integrated debugger. The features in- mainly implemented in C# and draws its installation procedure, which just in- clude the ability to toggle between the own controls [6]. The library requires a volves a few steps. Thanks to the wiz- Microsoft and Mono runtime environ- driver for each operating system: drivers ard, the installation problems that once ments and to import Visual Studio .NET for X11 and Windows are available at affected explicitly supported, but non- projects. this time of writing. The DotGNU project current, distributions (such as Fedora) has adopted this design after ditching a are a thing of the past. Some distribu- The Alternative: Mono Wine-based implementation as impracti- tions – such as Suse 9.3 – include Mono The Mono environment [5] is available cable. by default, but distros such as Red Hat for Linux, Windows, and Mac OS. Be- Besides the mcs compiler and the and Fedora tend to place their emphasis sides the .NET standard class libraries, mono runtime environment, the Linux instead on the Java platform. Mono has a few extensions, such as a version also has the monodevelop devel- There are a number of websites, such variety of Gnome libraries. The virtual oper environment, which is based on a as the one at [5], that document the machine adds just-in-time and ahead-of- Linux port of Sharpdevelop. The progress of the Mono project in detail. time build techniques for improved monodoc help browser, which allows For example, you will find an overview of the controls in the System.Windows. Listing 1: GUI with System.Windows.Forms Forms library at [6]. 01 #using System; FirstApp()); A Sample Application with 02 #using System.Windows.Forms; 11 # } Mono 03 # 12 # Existing Visual Studio .NET projects 04 #namespace LinuxMagazin. 13 # public FirstApp() : such as our sample application can be FirstApp base() imported directly into Monodevelop. But 05 #{ 14 # { don’t forget to adjust the references for the new project. The context-based help 06 # public class FirstApp : 15 # this.Text = "First when editing source code is one thing System.Windows.Forms.Form Application with GUI"; that you immediately notice about the 07 # { 16 # } developer environment, but the environ- 08 # public static void Main() 17 # } ment lacks a GUI builder at this time of 09 # { 18 #} writing. When we tried to build the code by 10 # Application.Run(new giving the mcs -r:System.Windows. WWW.LINUX - MAGAZINE.COM ISSUE 61 DECEMBER 2005 73 PROGRAMMING Mono and DotGNU Figure 3: The sample application running in Mono on Linux has diffi- Figure 4: The GUI-based .NET application has a few issues running in culty drawing the buttons at the top and the selection boxes on the DotGNU; for example, the radio buttons falsely trigger events multi- right. ple times. Forms.dll sourcefile command, the stan- ing commands build and launch the instead it draws the controls itself, just dard System.Windows.Forms.Numeri- HelloWorld application: like the Java Swing library. DotGNU does cUpDown control caused a problem, as it not implement an IDE of its own. is not completely implemented in Mono cscc -o HelloWorld.exe U as yet. After removing the offending HelloWorld.cs The Sample Project in code, we were able to build the applica- ilrun HelloWorld.exe DotGNU tion and launch it in the mono runtime DotGNU runs the bytecode generated on environment (Figure 3). The following command sequence Windows without any modifications. A number of errors occurred: for ex- builds a more complex project with a However, clicking on the RadioButton ample, the update mechanism, which graphical interface. The source code files controls initiated the event routine mul- handles redrawing in the application, are located in the src subdirectory: tiple times. This did not change when did not work properly when hidden by we rebuilt the source using DotGNU: another application. Additionally, the cscc -winforms -o U cscc --winforms -o DemoApp.exe *.cs. Ad- event mechanism had a some trouble Application.exe src/*.cs ditionally, we had to remove the Image- with the RadioButton and ComboBox ilrun Application.exe List handling code to get the application controls. to build. The implementation of the System.Win- Our tests managed to uncover another The Contender: DotGNU dows.Forms library is not based on a bug in the variant compiled with Dot- Based on the 0.7 version number as- graphical library such as GTK, but GNU (Figure 4). Our tests indictate that signed by the project, DotGNU is less mature than Mono. The core component Table 1: Comparing .NET Implementations of DotGNU is titled Portable .NET. It Project DotGNU Mono comprises three major components: Current Version 0.7.0 1.1.8 treecc (an aspect-oriented programming Copyright LGPL GPL or proprietary (selectable) tool), pnet (runtime environment, C# Operating systems Linux, Mac OS X, Windows Linux, Mac OS X, Windows compiler, programming tools), and Advantages pnetlib (C# system library with critical Standard package with Debian Standard package with Suse 9.3 C# class libraries). Original Windows bytecode can Supported by full-time developers Source code and RPM packages are be launched without modifications at Novell available from the DotGNU website. The Disadvantages RPM variant did not require any tweak- System.Windows.Forms not System.Windows.Forms not ing to give us a fully functional environ- completely implemented completely implemented ment; the tools all worked at first asking. Event handling error Event handling error Current distributions such as Debian 3.1 No developer environment Installation packages (Wizard) not make things even easier by actually in- adequately tested; for example, the cluding the DotGNU environment by de- developer environment is missing in Mono 1.1.7 fault (in the pnet package). The follow- 74 ISSUE 61 DECEMBER 2005 WWW.LINUX - MAGAZINE.COM Mono and DotGNU PROGRAMMING the event mechanism does not work pendent programming. The C# program- INFO properly: the GUI element RadioButton ming language is very similar to the Java triggered duplicate events.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us