O'Reilly logo

Mono: A Developer's Notebook by Niel M. Bornstein, Edd Wilder-James

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 1. Getting Mono Running

The labs in this chapter will guide you through obtaining, installing, and setting up Mono for Linux, Windows, and Mac OS X. The Mono system is comprised of the compiler, runtime, assemblies (code libraries), and documentation. In addition to these components, you will need a development environment and a build system. This chapter will cater to those needs too, whether using a graphical IDE or integrating Mono to fit snugly into your favorite and long-established editing environment.

Some of the labs in this chapter will only make complete sense after you’ve worked through Chapters 2 and 3, so feel free to come back and look around before you move on to Chapter 4.

Install Mono

Mono is distributed in three logical components: the Mono runtime and tools, the Mono API assemblies, and the Microsoft .NET compatibility API assemblies. Most of this book is about the Mono runtime, tools, and APIs, as described in the Preface. The exception is the coverage of ASP.NET, which allows you to develop web applications and web services.

Note

Starting at the beginning, how do you get your hands on Mono?

This lab describes how to obtain and install Mono, and the major accompanying assemblies. The majority of the labs in this book can be completed using the packages installed as part of this lab. Where additional downloads are required, they will be noted in each lab concerned.

How to do it

The best way to install Mono is to use the official packages. The Mono project has released precompiled packages for Linux (Red Hat, SuSE, and Fedora Core), Windows, and Mac OS X platforms. In addition, Linux distributions with their own download channels such as Debian or Gentoo have incorporated Mono into their usual repositories.

Note

We don’t control Mono’s web site, so you may find things change slightly. Keep an eye on the online errata for this book for any corrections.

Linux

Packages for Linux systems with an x86 family CPU are available from the Mono download page, which you can access by clicking the “Download” link on the Mono home page, http://www.mono-project.com/. Users of RPM-based systems ( Red Hat, SuSE, and Fedora Core) should download the RPMs suitable for their Linux distribution.

To make life easier, Fedora Core users can set up a yum channel. To do this, add the following code to /etc/yum.conf, adjusting the URL to that given for Fedora from the Mono download page, and run yum check-update to verify everything’s working.

[mono]
name=Mono 1.0
baseurl=http://www.mono2.ximian.com/archive/1.0/fedora-1-i386/

The download page explains the interdependencies of the packages. To obtain a functional Mono development environment, install the following packages: mono-core, mono-core-devel, mono-posix, mono-xml-relaxng, mono-data-postgresql, mono-data-sqlite, gtk-sharp, monodoc, mono-web-services, mono-remoting, and bytefx-data-mysql. Fedora Core users can use yum install to download and install these packages. Alternatively, you can download the RPMs and install them manually using rpm -i.

The Ximian Red Carpet package manager can also be used to simplify installation on Fedora Core, SuSE, and Red Hat platforms. Red Carpet can be downloaded from http://www.ximian.com/products/redcarpet/. Once installed, you can obtain the Mono packages from the Mono channel.

Users of Debian Unstable (on x86 or PowerPC) can install Mono using the following command, run as root:

# apt-get install mono monodoc gtk-sharp

Users of Gentoo Linux (on x86 or PowerPC) should compile and install Mono like this:

# export ACCEPT_KEYWORDS="~x86"
# USE="gtkhtml gnome" emerge mono monodoc gtk-sharp

Windows

Like Microsoft .NET, Mono requires Windows 2000 or later to run. To install Mono on Windows, download and run the installer from the download page at http://www.go-mono.com/. Gtk# is included in the installer.

The installer will deposit all the necessary files in C:\Program Files\Mono-1.0, but you can override that by entering a different folder.

Batch files that wrap each of the Mono executables will be installed in C:\Program Files\Mono-1.0\bin, so must add that to your PATH environment variable. The dialog box in Figure 1-1 will pop up after the installation to remind you to do this.

Mono Windows installer PATH reminder
Figure 1-1. Mono Windows installer PATH reminder

You can use the batch file setmonopath.bat to add the directory to your path:

C:\>"C:\Program Files\Mono-1.0\bin\setmonopath.bat"

Mac OS X

Mono requires Mac OS X 10.3 or later to run. For Gtk#, X11 is also required. To install X11 for Mac OS X, either download it from http://www.apple.com/macosx/features/x11/ or install it from the CD that came with Mac OS X 10.3. The X11 installer package will deposit everything needed to run X11 on your system.

Having installed X11, you must download and install Mono and Gtk#. Get the installer packages from the Mono download page at http://www.go-mono.com/. Be sure to read the documentation accompanying the packages.

Note

You should also find Mono available through the fink and DarwinPorts software installers.

Installing from source

Mono is supported on more platforms than there are binary packages. In particular, Mono works on Solaris, HP/UX, and PowerPC Linux. For these platforms, you must compile Mono from source.

You can obtain source packages from the Mono web site’s download page. Instructions for building from source can be found in the release notes. Mono itself is relatively straightforward to compile on Linux and Mac OS X, and is covered in this section. For Windows, you should check the release notes for special instructions.

Note

You might find third-party precompiled Mono packages for lesser-used platforms, but don’t count on it.

The minimum prerequisites for compiling Mono, aside from a functioning C compiler, are the development files for GLib. These will probably be available as libglib2.0-dev, glib2.0-dev, or glib2-dev packages on your Linux or Mac OS X system. They can also be compiled using the source code packages from ftp://ftp.gnome.org/pub/gnome/sources/glib/. Additional prerequisites for certain features are mentioned in the release notes but are not required for the labs in this book.

Decide where to install Mono to on your system, preferably not in /usr, which is normally managed by the system package manager. A good choice is /opt/mono. Configure and compile Mono using the following commands:

$ tar xfz mono-1.0.tar.gz
$ cd mono-1.0
$ ./configure --prefix=
                  /opt/mono
$ make
$ su
# make install

Now that Mono is installed, you must configure some environmental variables before you can use Mono. Use the following commands, substituting your own paths if necessary:

$ export PATH=
                  /opt/mono/bin:$PATH
$ export LD_LIBRARY_PATH=
                  /opt/mono/lib:$LD_LIBRARY_PATH # Linux only
$ export DYLD_LIBRARY_PATH=
                  /opt/mono/lib:$DYLD_LIBRARY_PATH # Mac OS X
$ export PKG_CONFIG_PATH=
                  /opt/mono/lib/pkgconfig
$ export MONO_PATH=
                  /opt/mono/lib

Download Gtk# source code from http://gtk-sharp.sourceforge.net/. Compiling Gtk# is somewhat more involved than Mono and is not covered here. If you are able to install the prerequisite libraries for compilation from source, it is likely that you have enough skill to handle the compilation process. You should refer to Gtk#’s release notes for compilation guidelines.

If you want to compile a development version of Mono from source code, see Section 8.4.

What about ...

...Using the Windows compatibility assemblies? The purpose of these assemblies is to smooth the migration of Microsoft .NET applications onto the Linux platform. The Windows.Forms user interface APIs will only work on x86 Linux, because of their dependence on the WINE system (http://www.winehq.com). WINE provides a compatibility layer to enable Windows-native code to execute on a Linux machine.

Although this book does not cover the compatibility assemblies in depth, you may quite reasonably want to install them. Packages can be downloaded from the Mono web site, marked as part of the “Microsoft .NET stack”. Details on compiling them from source are available in the release notes.

Explore Mono

The addition to class assemblies and documentation, the Mono distribution contains a variety of tools for creating and executing Mono programs. This lab takes you through a guided tour of the most important tools.

Note

Now you have Mono installed, what’s in the box?

How do I do that?

To get going with Mono, you must learn how to use the various command-line tools, especially mcs (the Mono C# compiler) and mono (the Mono virtual machine).

mcs

mcs is the Mono C# compiler. You can compile, embed resources, and link Mono programs by using mcs. Try compiling the Hello World example from Section 2.1 with mcs Hello.cs. The result should be a file called Hello.exe.

mcs doesn’t compile programs into directly executable code; rather, it compiles into an intermediate bytecode called Common Intermediate Language (CIL).

mono

The mono command executes a compiled Mono program in the virtual machine. mono uses a just-in-time compiler (JIT) to translate the compiled CIL bytecode to machine code for execution. The Hello.exe program can be run with mono Hello.exe.

Find out which version of Mono is installed by running mono —version. The output will look something like this:

Mono JIT compiler version 0.91, (C) 2002-2004 Novell, Inc
and Contributors. www.go-mono.com
        TLS:           NPTL
        GC:            Included Boehm (with typed GC)
        SIGSEGV      : altstack
        Globalization: ICU

Include this version information if you need to ask questions in any of the forums listed in Section 1.5.

mint

Not every platform on which Mono runs has the JIT compiler implemented yet. A slower alternative to mono is available in the form of mint, which interprets the CIL bytecode in real-time as the program is executing.

monodoc

Monodoc is the Mono documentation viewer, through which official Mono API documentation is available. It can be run with the command monodoc. As well as the official Mono APIs, any third-party assembly may also install its documentation so it can be viewed from Monodoc. One of Monodoc’s neat features is that it allows anyone to submit changes and additions to the documentation. These are sent to a central server and a human editor merges them into the official documentation repository. Figure 1-2 shows Monodoc in action.

The Monodoc documentation browser
Figure 1-2. The Monodoc documentation browser

monop

There are times when documentation may not be easy to find for a particular assembly. This is where monop comes in. monop can print out the signatures of any class for which the system has an assembly. For example:

$ monop System.Byte
public struct Byte : IComparable, IConvertible, IFormattable {
 
    public static byte Parse (string s, IFormatProvider provider);
    public static byte Parse (string s,
        System.Globalization.NumberStyles style);
    public static byte Parse (string s,
        System.Globalization.NumberStyles style,
        IFormatProvider provider);
    public static byte Parse (string s);
    public virtual int CompareTo (object value);
    public override bool Equals (object obj);
    public override int GetHashCode ( );
    public Type GetType ( );
    public virtual TypeCode GetTypeCode ( );
    public virtual string ToString (string format,
        IFormatProvider provider);
    public override string ToString ( );
    public string ToString (string format);
    public virtual string ToString (IFormatProvider provider);

}

If the class you need isn’t in the core system assembly, then the assembly name can be given on the command line:

Note

monop is a really handy tool for when all you need is a quick check on a method signature.

$ monop -r:NUnit.Framework NUnit.Framework.AssertionException

gacutil

To install a system library on a Linux system, you typically place it in /usr/lib or /usr/local/lib. On Windows, you put it in C:\WINDOWS\. With Mono and .NET, system-wide assemblies are stored in the Global Assembly Cache, (GAC). gacutil is used to manipulate the contents of the GAC. Information on gacutil can be found in Section 2.8, but a quick check on things can be made with gacutil -l, which lists all the assemblies stored in a system’s GAC. It’s another good way of finding version information, which can be very useful in filing bug reports.

What about ...

...The names of the commands? As all Mono programs compile to a file with .exe suffix, how come programs such as Monodoc aren’t run with mono monodoc.exe?

The answer is that Mono uses wrapper scripts to call the mono runtime program, to make the commands seem more natural in a Unix environment. If you intend to distribute your Mono programs, it’s a good idea to create similar scripts to make it easy for users. On some Linux systems, such as Debian, the Mono packages use a neat trick called binfmt. This allows the system to execute Mono .exe files directly. If using binfmt, you just need to make a symbolic link to the .exe without the suffix.

Note

Some Linux users get very upset to see a “Windows” file extension like .exe on their system!

Where to learn more

To find out more about the command-line applications Mono installs, try these following options. The quickest (but not always the most informative) way is to run the command with the —help. This should result in a brief aide-memoir to the program’s function being printed to the console.

Mono also ships with manual pages for use with the Unix system manual reader, man. For example, the function of the mysterious soapsuds command can be discovered by running man soapsuds. If your Mono is installed in a custom directory, such as /opt/mono, don’t forget to add /opt/mono/man to your MANPATH environmental variable.

Run the MonoDevelop IDE

MonoDevelop is a port of the SharpDevelop .NET integrated development environment (IDE) to Linux, using the Gtk# user interface toolkit. Both MonoDevelop and SharpDevelop are free, open source applications.

Note

Real men may use vi, but productive ones use an IDE.

As you work through the labs in this book, you’ll need a development environment to work in. While Section 1.4 provides hints on how to integrate Mono with an existing setup, this lab shows you how to get up and running with MonoDevelop. For the Mono 1.0 release, MonoDevelop is supported only on Linux, although some members of the Mono community have made it run on Mac OS X. See the “What about” section near the end of this lab for IDE solutions for Windows and Mac OS X.

MonoDevelop provides modern programming aids common to most IDEs, such as class browsing, integrated API documentation, build system, code completion, and support for multiple filetypes. Even if you’re a hardened command-line and text editor geek, it’s worth giving MonoDevelop a try. The integrated documentation is a great aid in navigating the many new APIs that Mono makes available.

How do I do that?

Source code and precompiled packages of MonoDevelop can be obtained from the project web site at http://www.monodevelop.com. If possible, use precompiled packages for installation, because the number of prerequisites required to compile MonoDevelop is a little daunting. Users of the Debian (unstable) or Gentoo Linux distributions should be able to locate a monodevelop package using apt-get or emerge.

Before taking a tour of MonoDevelop’s features, here’s a word about how it organizes source code. MonoDevelop solutions may contain one or more projects. A project contains one or more files, which are compiled and linked to create a target assembly. For small undertakings, such as those in this book, a solution is likely to contain only one project.

As a way of discovering MonoDevelop’s major features, this lab will lead you through creating a very simple Gtk# application. Start up MonoDevelop and choose New Solution/Project from the File menu. You should see a dialog similar to that shown in Figure 1-3. Navigate to the options for C#, and click on Gtk# Project. Name the project and choose a location in your home directory for it. Then click New to create the MonoDevelop solution.

Creating a solution in MonoDevelop
Figure 1-3. Creating a solution in MonoDevelop

When you tell it to create a new solution, MonoDevelop creates several files: AssemblyInfo.cs, which contains metadata about your project and is described in more detail in Section 2.8, Main.cs, containing the main function of the program; and MyWindow.cs, containing the application window class. Navigate to MyWindow.cs using the solution viewing panel, shown in Figure 1-4, and double-click on MyWindow.cs to make its source appear in the source code window.

MonoDevelop’s solution browser
Figure 1-4. MonoDevelop’s solution browser

Position the cursor at the end of the this.ShowAll () line in MyWindow.cs, press Enter to create a new blank line, and type this.Ti. The code completion window will appear, as shown in Figure 1-5. The mouse can be used to scroll up and down the list of possible completions, with the signature of each completion showing in the “tool-tip” window near the completion list. Press Enter to select the this.Title completion (you can press Escape to close the completion window). Code completion can be reactivated during editing by using the Ctrl-space keys combination.

Code completion in MonoDevelop
Figure 1-5. Code completion in MonoDevelop

In addition to code completion, MonoDevelop integrates the full API documentation provided by Monodoc. Access this by selecting the Help tab in the left panel and using the tree to browse to the desired part of the APIs. Figure 1-6 shows the help browser in action.

Integrated API documentation in MonoDevelop
Figure 1-6. Integrated API documentation in MonoDevelop

As well as browsing the Mono APIs, MonoDevelop presents a structured view of the classes in each project. Click on the Classes tab in the left panel, and expand the tree to explore the classes in your project. The view should look something like Figure 1-7. Double-clicking on a definition will move the cursor to the corresponding point in the source code.

MonoDevelop’s class browser
Figure 1-7. MonoDevelop’s class browser

MonoDevelop has an internal build system that will recompile any source code changed since the last build. The easiest way to access this is by using the compile-and-run (“gears”) button on the toolbar. This will compile and then run the project currently being edited. Any errors will show up in the task list window, visible at the bottom of Figure 1-6. Try inserting a deliberate syntax error, and hit the compile-and-run button. The result should be similar to that in Figure 1-8. Double-clicking on the error report positions the cursor at the offending line in the source code. Finally, when you correct all the errors, press compile-and-run and MonoDevelop will run the program. As well as opening the Gtk# window MyWindow, MonoDevelop opens a console window to show anything that is printed to the standard output. Because would not have supplied any window closing code you will need to hit Ctrl+C in the console window to terminate the program. (See Section 4.1 for details of how to add code to close the window)

Errors during compilation in MonoDevelop
Figure 1-8. Errors during compilation in MonoDevelop

Note

Figure 1-7 shows a mysterious function called ctor. This is short for constructor, and is an abbreviation commonly used in Mono.

What about ...

...IDEs for Windows or Mac OS X? Windows users need to look only as far as SharpDevelop, mentioned in the introduction to this lab. SharpDevelop can be configured to compile programs with Mono. MonoDevelop can load SharpDevelop projects and solutions directly. More information can be found at the SharpDevelop web site at http://www.sharpdevelop.com/.

Note

You can build a MonoDevelop project from the command line with make by downloading prj2make from http://forge.novell.com and creating a makefile from the MonoDevelopment project’s prix file.

The situation is a little less straightforward for Mac OS X users. Some members of the Mono community have been able to compile MonoDevelop for OS X, and in time it is likely that precompiled packages will be published. Additionally, work is ongoing in creating the necessary files to configure XCode, the IDE that Apple ships with OS X, for use with Mono projects. Visit http://www.druware.com/ for more information on XCode integration. Also, keep an eye out for details of Mac OS X IDE support on the mailing lists and news sites described in Section 1.5.

Fit Mono into Your World

Everybody has their preferred development environment, whether it’s just a text editor or a full-blown IDE. While Mono has a great IDE in the form of MonoDevelop, there may be many reasons for continuing with your current environment.

Note

Development environments are a near-religious issue. Mono won’t make you abandon your favorite tools.

This lab shows how Mono can be integrated with some of the more common tools used by Linux and Java developers.

How do I do that?

If you are an old-school geek, you probably prefer to write your code with a text editor such as Emacs or Vim. Support for editing in C# ships as part of Vim 6.2, which can be found at http://www.vim.org/. Emacs users should install Brad Merrill’s C# mode, available from http://www.cybercom.net/~zbrad/DotNet/Emacs/.

Note

Brad Merrill has worked on .NET at Microsoft since 1999, so he’s had plenty of time to refine his Emacs C# mode!

Unix geeks will also be familiar with using make to build their programs. It’s simple to use make to control the building of Mono programs. The most obvious difference from C and C++ is that Mono doesn’t need intermediate object files, so all the source files must be given to the compiler at once. Example 1-1 shows an example makefile that can be used as a starting point. The accompanying source files used by this makefile are available from the book’s web site.

Example 1-1. Using make with Mono: 04-integrate/Makefile
# 01-tooling/04-integrate
MCS = mcs

ifdef DEBUG
MCSFLAGS = -debug
endif

.PHONY: clean all

all: SimpleMain.exe Main.exe FatMain.exe Library1.dll

# default way to make executables
%.exe: %.cs
  $(MCS) $(MCSFLAGS) -target:exe -out:$@ $(filter %.cs,$^) \
    $(foreach dl,$(filter %.dll,$^),$(addprefix -r:,$(dl)))

# default way to make libraries
%.dll: %.cs
  $(MCS) $(MCSFLAGS) -target:library -out:$@ $(filter %.cs,$^) \
    $(foreach dl,$(filter %.dll,$^),$(addprefix -r:,$(dl)))


# SimpleMain.exe is automatically built from its sole
# source file, SimpleMain.cs

# Main.exe has two source files and links with Library1.dll
Main.exe: Main.cs Sprockets.cs Library1.dll

# Library1.dll is automatically built from its sole 
# source file, Library1.cs

# FatMain.exe has some resources, and links against Library1.dll
# define them in variables, let make do the walking
FATMAIN_RESOURCES = monkey.png readme.txt
FATMAIN_SOURCES = Main.cs Sprockets.cs Widgets.cs
FATMAIN_LIBS = Library1.dll

FatMain.exe: $(FATMAIN_SOURCES) $(FATMAIN_RESOURCES) $(FATMAIN_LIBS)
  $(MCS) $(MCSFLAGS) -target:exe -out:$@ \
    $(foreach res,$(FATMAIN_RESOURCES), \
      $(addprefix -resource:,$(res))) \
    $(foreach dl,$(FATMAIN_LIBS),$(addprefix -r:,$(dl))) \
    $(FATMAIN_SOURCES)

clean:
  rm -f *.exe *.dll

Running make with the makefile in Example 1-1 yields the following output:

Note

You can have the best of both worlds, of course. The MonoDevelop IDE generates makefiles for its projects.

$ make
mcs  -target:exe -out:SimpleMain.exe SimpleMain.cs \
 
Compilation succeeded
mcs  -target:library -out:Library1.dll Library1.cs
Compilation succeeded
mcs  -target:exe -out:Main.exe Main.cs Sprockets.cs \
        -r:Library1.dll
Compilation succeeded
mcs  -target:exe -out:FatMain.exe \
         -resource:monkey.png  -resource:readme.txt \
        -r:Library1.dll \
        Main.cs Sprockets.cs
Compilation succeeded

Developers coming from the Java world are more likely to be familiar with the Ant build tool than with make. The Mono and .NET world has a similar tool, called NAnt. You can download NAnt from the web at http://nant.sourceforge.net/. Be sure to read the accompanying documentation for Mono-specific notes on building and installing NAnt.

NAnt supports many .NET-specific build tasks, such as running unit tests with NUnit (see Section 3.8). Examples and further documentation are available on the NAnt Wiki, linked from the project’s web site. Example 1-2 shows a NAnt build configuration that performs the same tasks as the makefile from Example 1-1 when invoked with mono /path/to/NAnt.exe (adjust the path to wherever you installed NAnt).

Note

For best results with Mono, use NAnt version 0.85 or better.

Example 1-2. Using NAnt with Mono: 04-integrate/monodn.build
<project name="monodn" default="all">
    <target name="all">
        <call target="SimpleMain" />
        <call target="Library1" />
        <call target="Main" />
    </target>

    <target name="SimpleMain">
        <csc target="exe" output="SimpleMain.exe">
            <sources>
                <includes name="SimpleMain.cs" />
            </sources>
        </csc>
    </target>
    
    <target name="Library1">
        <csc target="library" output="Library1.dll">
            <sources>
                <includes name="Library1.cs" />
            </sources>
        </csc>
    </target>

    <target name="Main" depends="Library1">
        <csc target="exe" output="Main.exe">
            <sources>
                <includes name="Main.cs" />
                <includes name="Sprockets.cs" />
            </sources>
            <references>
                <includes name="Library1.dll" />
            </references>
        </csc>
    </target>

    <target name="FatMain" depends="Library1">
        <csc target="exe" output="FatMain.exe">
            <sources>
                <includes name="Main.cs" />
                <includes name="Sprockets.cs" />
                <includes name="Widgets.cs" />
            </sources>
            <references>
                <includes name="Library1.dll" />
            </references>
            <resources>
                <includes name="readme.txt" />
                <includes name="monkey.png" />
            </resources>
        </csc>
    </target>
</project>

Many Java users will also be familiar with the Eclipse IDE. A C# editing and compilation plugin is available for Eclipse, from a company called Improve. The plugin is open source and can be downloaded from Improve’s web site at http://www.improve-technologies.com/. After downloading and installing the plugin, configure it with the path of the Mono C# compiler. To find this setting, select the Preferences from the Window menu, and select the C# Preferences section.

Improve’s C# plugin, shown in Figure 1-9, offers syntax highlighting, code indentation, and compilation. The C# editing features are not as advanced as in MonoDevelop (described in Section 1.3). For instance, code completion and API documentation is lacking. However, if your environment of choice is Eclipse, the C# plugin is a good start. And not to be forgotten is the variety of Eclipse’s other handy features, such as wealth of editor plugins and CVS source code repository support.

C# editing in Eclipse
Figure 1-9. C# editing in Eclipse

What about ...

...Windows developers who don’t want to use IDEs? After all, many Mono projects don’t come in a form that fits nicely into SharpDevelop or Eclipse. All is not lost! For many years now the cygwin project has provided ports of the GNU developer toolchain and command-line tools to the Windows platform. Cygwin is impressively comprehensive, including (among other things) the bash shell, used throughout this book, the make build tool, and the XFree86 windowing system. Cygwin can be downloaded and installed from http://www.cygwin.com/. With a little bit of care, a developer on the Windows-Cygwin environment can perform all the same command-line and compilation tasks that Linux and Mac OS X developers can.

Where to learn more

As Mono grows in popularity, more resources will become available for using it in both traditional Unix environments and integrated with Mac OS X and Windows. To learn of new resources, keep an eye on the forums described in Section 1.5, as well as some Microsoft-focused ones such as http://blogs.msdn.com/.

Comprehensive documentation for GNU make is provided on the GNU project’s web site at http://www.gnu.org/software/make/. Users of GNU autoconf and automake should read Section 8.1, which shows how to create an example project using these tools.

Join the Mono Community

One of the few disadvantages of this book is that, once printed, it can’t change to cover the latest developments in the Mono world. Happily, help is at hand. Mono is a vibrant and evolving open source project, with a growing community of active developers and users. As such, there’s a wide variety of online resources you can use to get news, help, and new tools for Mono.

Note

Don’t struggle on your own, there’s a world of help out there!

This lab introduces the major Mono community resources and shows how to get the best out of them. As you continue to read through this book, familiarity with the Mono’s online resources will help you in your exploration of Mono.

How do I do that?

Before jumping into forums or mailing lists with questions, it’s a good idea to make yourself as familiar as possible with Mono, its documentation, and recent developments. The first stopping-off point is the Web, where news, answers to common questions, and a variety of tutorials can be found.

Mono web site

Available at http://www.go-mono.com/, the Mono web site is the authoritative source for information on Mono. As well as a host of documentation, the Mono web site publishes the latest news about the project. The comprehensive list of frequently asked questions is a good resource for answering questions technical and commercial alike about Mono. The API documentation that ships with Monodoc is also available on the Web, by following the “Documentation” link.

MSDN

As the originators of .NET and the Common Language Runtime, Microsoft obviously has a lot to say on the topic. The Microsoft Developer Network, http://msdn.microsoft.com, contains a wealth of reference material and tutorials on using C#, and the APIs common to both Mono and the Microsoft .NET framework.

O’Reilly Network

An online magazine run by the publishers of this book, the O’Reilly Network regularly publishes articles for developers on development with .NET, keeping up with the latest happenings in the Mono and .NET world. You can access the O’Reilly Network at http://www.oreillynet.com/.

Monologue

Many from the team of developers responsible for maintaining Mono, including project founder and leader Miguel de Icaza, regularly update their weblogs. These are aggregated online at a site called Monologue, which you can find at http://www.go-mono.com/monologue/. Reading Monologue is a good start if you wish to get involved with the Mono project yourself, care about the internal details of its implementation, or are interested in the sometimes amusing and off-beat reflections of its developers.

Mailing lists are a popular way of receiving peer support for technologies. There are several mailing lists that Mono users should consider joining in order to receive (and give!) help and find release announcements for Mono-related software. A full list of mailing lists is available linked from the Mono home page. Here are the ones most useful for developers starting out with Mono.

mono-announce

The Mono announcement list is a low-volume mailing list, carrying news of new Mono releases and important community events. It is a moderated forum, so any posts to it must be approved by Mono project staff before they are distributed. Subscription information for mono-announce is available from http://lists.ximian.com/mailman/listinfo/mono-announce-list.

mono-list

The Mono list is the main forum for developers who are building programs using Mono. Anybody can participate in this list. Before posting to the list, it’s a good idea to look through the archives to see if somebody else has posted the same question before. Subscription information is available from http://lists.ximian.com/mailman/listinfo/mono-list.

gtk-sharp-list

The gtk-sharp-list is focused on issues surrounding development with, and the development of, the Gtk# user interface assemblies for Mono. Subscription information is available from http://lists.ximian.com/mailman/listinfo/gtk-sharp-list.

Software inevitably has bugs, and despite the quality of its developers, it’s possible you will come up against a bug in Mono. Often, there’s a good chance somebody else has this problem too. For this reason, Mono has a bug tracking database, implemented using the popular bugzilla system. By accessing the bugzilla at http://bugzilla.ximian.com/ you can search to see if your problem has already been reported. If it hasn’t been reported, you can use bugzilla to file a new problem report. Although some bugs will inevitably get discussed on the mailing lists, the Mono developers vastly prefer to get bug reports in bugzilla as it enables them to track and organize the bugs more effectively.

Note

Do your homework first and you’ll get the best out of the Mono development community.

When reporting bugs, the more information you can give, the better. Ensure you include:

  • Your operating system, distribution, kernel version if appropriate, and CPU family.

  • The version of Mono for which the bug occurs. Obtain this by running mono —version. If the problem is with Gtk#, find out the version by running pkg-config —version gtk-sharp.

  • What makes the bug occur, and how to reproduce it. Where appropriate report what you expected to happen, and what actually did happen.

  • A test case. You may not always be able to create one, but a small program that demonstrates the problem is very helpful.

As a developer, one of the ways in which you can learn is by looking at the source code of, and possibly getting involved with, open source projects that use Mono. Additionally some of these projects might be code libraries that will prove useful in your own projects. Some useful resources and projects include:

Novell Forge

A collection of projects rather than an individual project, Novell Forge is a community site where Novell and others release open source software. Many of these projects use Mono, including the iFolder file-sharing system, LDAP libraries for directory services, and a multicast DNS responder. Novell Forge’s URL is http://forge.novell.com/.

F-Spot

F-Spot is an open source photo management program for the GNOME desktop platform. Its source code uses both C and C#, and is available from the GNOME CVS repository at http://cvs.gnome.org/.

Dashboard

Dashboard performs a continuous search of your personal information space, showing results relevant to the current desktop activity. For instance, if you are reading an email from your friend Jane Doe, Dashboard will show the recent instant messaging conversions that you have had with Jane, a summary of the most recent emails she has sent you, Jane’s contact details, a list of documents written by or mentioning Jane, and so on. Dashboard is a multithreaded application using Gtk# for the user interface and completely implemented in C#. Dashboard has quite a broad community of contributors, and its own mailing list. More information is available at the Dashboard home page, http://nat.org/dashboard.

Finally, should you wish to engage in real-time chat with Mono users and developers, there is an Internet Relay Chat (IRC) channel for talking about Mono. Configure your IRC client for the http://irc.gimp.org server, channel #mono. As with any forum, there are rules of etiquette for IRC. It’s a good idea just to “lurk,” that is keep quiet and listen, for a while to determine the conventions of the channel. If you don’t receive answers to your questions, don’t keep repeating them ad nauseam, it’s just likely that others are busy with other things.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required