Search code examples
c#firefox4geckofx

GeckoFX Update for Gecko 2.0?


I was really excited when I found GeckoFX last month. My employer wants to distribute an embedded browser with our desktop application (to smooth the transition from desktop-based apps to web-based apps), and being able to use Gecko rather than IE was a miracle!

The latest versions of GeckoFX I can find use versions 1.9.1 and 1.9.2 of the Gecko engine (Xulrunner). This works just fine, but it's missing a lot of the goodies that shipped with Firefox 4 (Gecko 2.0) this week.

I already have the distribution of Xulrunner 2.0, but GeckoFX won't work with it out of the box. Some of the XPCOM API has changed, and I'm sure there are a lot of other minor incompatibilities. I'd say it should be an easy fix, but I'm not a C++ developer so I really have no idea.

What I'm looking for right now is one of the following, in order of preference:

  1. An already-built update of GeckoFX that's compatible with Xulrunner 2.0
  2. Another solution that allows me to embed a Gecko-powered web browser in a C# Windows application.
  3. Advice on where to start to update GeckoFX myself (by advice I mean hold-my-hand-and-talk-to-me-like-I'm-6 advice)

Just digging in to the code and trying to sort through all the errors doesn't help. I keep getting an InvalidCastException when trying to create an instance of nsIWebBrowser (and no, I can't get more descriptive than that because that's all the error message and stack trace show!). It's been a lot of head scratching and pointless Googling since it seems no one's kicked off an embedded Firefox 4 yet.

Ideas? Suggestions?


Solution

  • In the absence of deeper help, I took the time to dig in and figure things out on my own. The trick was understanding ComImport, which is something I haven't used before.

    It turns out, Mozilla changed the GUIDs of some of the API methods exposed by XPCOM. Most importantly, the GUID for nsIWebBrowser changed from 69E5DF00-7B8B-11d3-AF61-00A024FFC08C to 33e9d001-caab-4ba9-8961-54902f197202.

    Making this one change in nsInterfaces.cs actually fixed quite a bit.

    Going through line-by-line and reconciling build errors (despite cryptic error messages) allowed me to finish out the system and create a build that does indeed run XULRunner 2.0.

    Unfortunately, being able to build and run Gecko 2 and exposing the entire API are two very different things. I've created a project on Google Code to house a complete rewrite of GeckoFX for Gecko 2: Leapin' Lizard. It's essentially a fork of the original Skybound.Gecko code, and distributed under the same open source licenses.

    So I now have a build of GeckoFX that's compatible with XULRunner 2.0. It just needs to be polished.