Click here to Skip to main content
13,860,564 members
Click here to Skip to main content
Add your own
alternative version


32 bookmarked
Posted 6 Nov 2003

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


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


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 -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!


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


About the Author

victor vatamanescu
Web Developer
Romania Romania
No Biography provided

You may also be interested in...


Comments and Discussions

Generalwindows.forms Pin
codeJuice7-Nov-03 1:55
membercodeJuice7-Nov-03 1:55 
GeneralRe: windows.forms Pin
Giles7-Nov-03 2:39
memberGiles7-Nov-03 2:39 
GeneralRe: windows.forms Pin
Daniël Pelsmaeker9-Nov-03 5:03
memberDaniël Pelsmaeker9-Nov-03 5:03 
GeneralRe: windows.forms Pin
Dennis Hayes11-Nov-03 9:44
memberDennis Hayes11-Nov-03 9:44 
GeneralRe: windows.forms Pin
Leonardo Pessoa5-Apr-05 3:30
memberLeonardo Pessoa5-Apr-05 3:30 
GeneralRe: windows.forms Pin
Member 6407236-Oct-04 5:48
memberMember 6407236-Oct-04 5:48 

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

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

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