Click here to Skip to main content
Click here to Skip to main content

Building applications with Mono

, 6 Nov 2003
Rate this:
Please Sign up or sign in to vote.
Developing .NET cross platform applications using mono and IBM DB2

Introduction

MONO is an open source project started in 2001 under the coordination of Ximian, with the purpose of developing an open source, cross platform implementation of the .NET Framework. In this article, I will show the basics of building a distributed application using Mono. The application was written in C# on a RedHat 9 based system. It uses IBM DB2 as a database backend, the SAMPLE database that ships with DB2 and my IBM DB2 open source managed provider (included in the zip attached).

Description

This sample application is divided in 2 conceptual components: a server component accessible using .NET Remoting and a GUI application written in C# with GTK#. I chose to use this GUI toolkit because it is much more flexible and in some points much more mature than Windows.Forms and it has the big advantage of being truly cross platform. It also has the big advantage of having a really easy to use interface designer - GLADE. The interface is saved in XML based files that can be easily imported in the C# code using the Glade.XML class. As a matter of fact, you can even define the events your application will handle and specify the functions handling each event, inside GLADE.

For running on a Windows machine, GTK will need the cygwin environment.

The server component is a data source for the client application. To keep the example simple, it only returns an ArrayList which contains employee related data from the SAMPLE database. The client application will receive this ArrayList and will insert the employee data in a GtkTreeView (a flexible equivalent of more Windows.Forms components, a DataGrid in this particular case).

Building the code

  1. The IBM DB2 Managed Provider

    On Linux with Mono:

     mcs -unsafe -target:library /d:OS_LINUX -r:System.Data.dll 
                            -out:System.Data.Db2Client.dll  *.cs

    On Windows with Mono:

    mcs -unsafe -target:library /d:OS_LINUX -r:System.Data.dll 
                           -out:System.Data.Db2Client.dll  *.cs

    The managed provider can also be used with Microsoft .NET Framework implementation:

    csc -unsafe -target:library /d:OS_LINUX -r:System.Data.dll 
                          -out:System.Data.Db2Client.dll  *.cs
  2. The EmployeeManager component
    mcs -r:System.Data.dll -r:System.Data.Db2Client.dll remotable.cs
  3. The server component:
    mcs -r:System.Runtime.Remoting.dll -r:remotable.dll server.cs
  4. The client component:
    mcs -target:exe -resource:db2test.glade -r:remotable.dll 
       -r:System.Runtime.Remoting.dll -r:gtk-sharp.dll 
       -r:glade-sharp.dll -out:sample.exe sample.cs

Running the code

  1. Launch the server:
    [db2inst1@linux db2test]$ mono server.exe

    The server must be launched by a user that has DB2 rights.

  2. Launch the client:
    mono sample.exe

    If you encounter any problems running this sample or if you have any questions related to using mono, please don't hesitate to contact me at victor.vatamanescu @ hqsoftware . ro (spaces are used for spam protection).

Happy hacking!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

victor vatamanescu
Web Developer
Romania Romania
No Biography provided

Comments and Discussions

 
Generalwindows.forms Pinsussm¿nkey Fish7-Nov-03 1:55 
GeneralRe: windows.forms PinmemberGiles7-Nov-03 2:39 
The Windows.Forms part is still under heavy development, but quite a bit of it works well. It makes use of Wine (Win32 emulator in Linux), so you can even do p-invokes etc.
 
Ximian recently released a roadmap for the first full release of Mono 1.0 which should be in the begining of the next year I think, which should be compatible with .NET 1.1 I think.
 



"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
 
Shameless Plug - Distributed Database Transactions in .NET using COM+
GeneralRe: windows.forms PinmemberDaniël Pelsmaeker9-Nov-03 5:03 
GeneralRe: windows.forms PinmemberDennis Hayes11-Nov-03 9:44 
GeneralRe: windows.forms PinmemberHarkos5-Apr-05 3:30 
GeneralRe: windows.forms PinmemberModesto San Juan6-Oct-04 5:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 7 Nov 2003
Article Copyright 2003 by victor vatamanescu
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid