Announcing Mono.Zeroconf

I started working on Mono/.NET bindings to Bonjour/mDNSResponder almost two years ago. The code was quite useful but we found ourselves adding a lot of nasty preprocessor directives — yes, in C# — and configure junk to support both Mono.Zeroconf (Bonjour) and Avahi in software like daap-sharp and Banshee.

Earlier this year I found some time to start finishing my grand goal for Mono.Zeroconf — to support both Avahi and Bonjour through a simple, unified API.

Say what, exactly?

Today Mono.Zeroconf provides an easy to use API that covers the most common operations for mDNS (Browsing, Publishing, full TXT record support). It works either against Avahi (via the avahi-sharp bindings) or Bonjour on Linux, Windows, and Mac.

If your application needs to be cross platform (or even just cross-distro if you’re concerned about targeting older Linux distros) and perform Zeroconf networking, Mono.Zeroconf is the library for you. On Windows, the Mono.Zeroconf binaries work under both Mono and .NET.

It should be noted that Mono.Zeroconf does not support many of the more advanced mDNS features that Avahi in particular exposes. It is an intersection of the most common operations supported by both Bonjour and Avahi.

If your application needs advanced mDNS features, you most likely will care about the mDNS provider that you actually use (and I hope you choose Avahi). Therefore, I do not expect the functionality of Mono.Zeroconf to expand much and the current API is considered stable and complete. I may however add domain enumeration support in the future if it becomes a requested feature.

And how do I use it?

There are a couple of C# examples on the Mono.Zeroconf page that show how to browse, resolve, and publish services through Mono.Zeroconf. Here’s a quick adapted example on how to browse:

using Mono.Zeroconf;
ServiceBrowser browser = new ServiceBrowser ();
browser.ServiceAdded += delegate (object o, ServiceBrowseEventArgs args) {
    Console.WriteLine ("Found Service: {0}", args.Service.Name);
    // Connect to args.Service.Resolved event
    // Call args.Service.Resolve ()
browser.Browse ("_daap._tcp", "local");

There is also a small command line utility included in Mono.Zeroconf called mzclient. This works much like the traditional Bonjour command line tool, but it’s slightly nicer in ways I don’t remember. The source code to mzclient is probably the best example on what Mono.Zeroconf can do and how to do it.

Monodoc API documentation is also available.

Where is it?

Mono.Zeroconf will be part of the tarball set for the next Mono release (1.2.7). It is a separately maintained project and not bound to the Mono release schedule, but the upstream sources will be available in the same place. Packages will also be available through official Mono repositories.

For now, I have released sources on the Banshee web site. Packages (noarch) are available through the wonderful openSUSE Build Service for openSUSE Factory, 10.3, 10.2, 10.1; SLE 10; and Fedora 6, 7, and 8.

Sebastian Dröge is pushing it into Debian and Ubuntu, so packages should be available there soon. Will Farrington is working on a Conary recipe for Foresight.

Mono.Zeroconf is of course available in Mono SVN:

$ svn co

9 Replies to “Announcing Mono.Zeroconf”

  1. The next release will probably feature a build for Windows, but in the mean time you can just download the .zip file for releases which contains pre-compiled binaries that work on Mono or .NET against Bonjour on Windows.

    Or you can build on Linux and copy over the binaries:

    $ ./configure –disable-avahi –disable-docs && make
    $ find \( -name *.dll -o -name *.exe \) -exec scp {} user@host:dir/ \;

  2. Aaron,

    I try to compile the Mono.Zeroconf in Ubuntu Gutsy, but i got a problem.

    When i command the “make install”, the assembly doesn’t register.

    The problem is in the command gacutils, the make inform the params -root and -gacdir, but it is not necessary. In this case, the script have sucessfull, but when i try to compile something that uses Mono.Zeroconf i got the error that the assembly doesn’t exists.

    To solve this, i only command the gacutils without the params -root and -gacdir.

  3. I was able to build your MZClient source code in VS2008 but it throws an exception “No Zeroconf providers could be found or initialized. Necessary daemon may not be running.” I have Bonjour for Windows installed and your MZClient.exe which is in the binary .zip works fine.

  4. You need all of the assemblies in the same directory, or properly installed in the GAC for mzclient to work. Read the “Providers” [1] section on the Mono.Zeroconf Wiki page for more details on how providers are resolved at runtime.

    mzclient worked in the .zip file because all of the assemblies were in the same directory. That’s probably not true when building in VS, though I’ve never tried.


  5. Hey guys,

    I am working on Mono.ZeroConf with .NET Studio 2008 and i am focusing in the security aspects. In other words, what are the security vulnerabilities in Mono.ZeroConf ? I will greatly appreciate any help on this matter because i am stuck at this point and i need this information.

    Thanks in advance.

Comments are closed.