Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


An Introduction to Mono Development : Page 5

Microsoft's .NET Framework CLI implementation isn't the only CLI development game in town. The Mono project is both surprisingly mature, and surprisingly compatible—and you can deliver applications built on it to multiple platforms, including Windows.




Application Security Testing: An Integral Part of DevOps

Building a Windows Forms Client Program
Before continuing, be sure to rename DontUseCoreLibDumper.dll back to CoreLibDumper.dll. Next, create a new C# file named WinFormsClientApp.cs. This file defines two types, both of which make use of a few C# 2.0 language features, including static classes and anonymous methods. Listing 2 contains the complete code.

To compile this Windows Forms application using a response file, create a file named WinFormsClientApp.rsp (shown below) and supply that as an argument to gmcs.exe as shown previously.

Figure 6. A Mono-based Windows Forms Application: The figure shows a Windows Forms client that calls CoreLibDumper to dump type members to a text file.

/target:winexe /out:WinFormsClientApp.exe /reference:CoreLibDumper.dll /reference:System.Windows.Forms.dll /reference:System.Drawing.dll WinFormsClientApp.cs

Finally, run your Windows Forms application via mono.exe:

mono WinFormsClientApp.exe

Figure 6 shows the output.

Author's Note: Although this simple Forms-based UI compiles and executes without error, it is important to point out that as of Mono 1.1.15, the implementation of System.Windows.Forms.dll has not been finalized. To date, "Mono Windows Forms" (or simply MWF, the name given to Mono's System.Windows.Forms.dll assembly) is just about complete. Check out http://www.mono-project.com/WinForms for further details of Mono's Windows Forms project.

Figure 7. Linux Version: Here's the WinFormsClientApp.exe running on SuSe Linux with no code changes.
The Proof Is In the Pudding
Up until now, this article has shown you nothing regarding the .NET base class libraries or the C# programming language that you have not already seen from Microsoft's CLR. However, the importance of Mono becomes quite clear when you view Figure 7, which shows the same exact Windows Forms application running under SuSe Linux.

So, you can compile and execute the same exact C# code shown during this article on Linux (or any OS supported by Mono) using the same Mono development tools. In fact, you can copy the assemblies built on here on Win32 to a new OS and run them directly, with no recompile or code modifications required. Just use the mono.exe utility on the target system to run the applications.

Figure 8. The Monodoc Application: The figure shows a sample page from the Mono documentation library.
Exploring Mono with MonoDoc
To wrap up and give you a path to proceed, Mono ships with a local help system, named Monodoc, which provides documentation of the Mono base class libraries and the C# programming language. You can launch this utility from a Mono command prompt or via the Start | All Programs | Mono For Windows | Applications menu option (see Figure 8).

As you look over the entries within MonoDoc, you will most certainly find a number of incomplete listings, because MonoDoc relies on the Mono community to provide the documentation of the base class libraries (in fact, you can contribute to the documentation from within MonoDoc itself!).

Future articles in this series will dig deeper into the details of Mono development, but this should get you started, and ready for further exploration.

Andrew Troelsen is a .NET trainer and consultant for Intertech Training, a .NET and J2EE education and development company. He is the best-selling author of numerous books on .NET and COM (including the award winning C# and the .NET Platform) and speaks at numerous corporate and academic conferences around the country.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date