Using GeckoFX instead of .NET WebBrowser Control

GeckoFX is a .NET control, that works similarly to “System.Windows.Forms.WebBrowser” Control, while being cross platform, and offering much more control, it is in my opinion, a great replacement for the “System.Windows.Forms.WebBrowser”.

GeckoFX is based on the same engine as Firefox, the Mozilla Gecko.

This is an example on how to use it in Visual Studio.

This is a great replacement for Forms.WebBrowser control.

To get this working, you need to first download the GeckoFX from here:

During the writing of this, the last available version was the “GeckoFX-29.0”, so I downloaded that from here, if while you download this found a newer version, which is very likely, be careful to what XUL version you download on the next step:

and last revision:

After that, you need to download the XULRunner runtime from Mozilla website, it is very important that you download a version from here that matches the same version as the GeckoFX version.

Here is a version list that will help you know what XULRunner version you need:

And download from:

In my case, I downloaded version “29.0” from:

Extract the contents of the archive in the same folder as the executable, the same folder that has the WindowsFormsApplication1.exe, if you choose to extract to a different folder, be sure to modify the code to point to the new folder.

After that, start Visual studio, create a new C# Windows form project, and add refrences to both “Geckofx-Winforms.dll”, and “Geckofx-Core.dll” in the project refrences.

You may also need to add those line to the top of the file:

using Gecko;
using System.IO;
using System.Linq;
using System.Reflection;

And in the form constructor, you need to add some code to initiate the GeckoFX control, this code will be added after the “InitializeComponent()” function call, like this:

    GeckoWebBrowser browser;
    public Form1()
        var app_dir = Path.GetDirectoryName(Application.ExecutablePath);
        Gecko.Xpcom.Initialize(Path.Combine(app_dir, "xulrunner"));
        browser = new GeckoWebBrowser();
        browser.Dock = DockStyle.Fill;
        this.browser.Name = "browser";

And add this one line to the form load event handler:

    private void Form1_Load(object sender, EventArgs e)

Important Problem: you need to go to your project properties, and in the ‘build’ tab, change the platform target to x86 for (all configurations), instead of “Any CPU”.

Before running the application for the first time, do not forget that you need to extract the xulrunner in the “\bin\Debug” or “\bin\Release” folder.

This is the result:


2 thoughts on “Using GeckoFX instead of .NET WebBrowser Control”

  1. Hey! I need your help! I want to handle events to the browser engine. How I can do that? Please contact me! Nice tutorial 🙂

    1. I’m using VB.NET
      I got it. I don’t need help anymore.
      When I’m using:
      “Public browser As GeckoWebBrowser”
      I writed “WithEvents” after “Public”
      And I got this:
      “Public WithEvents browser As GeckoWebBrowser”
      So, thanks for this tutorial 😉

  2. YimLoPowe says:
    Your comment is awaiting moderation. This is a preview, your comment will be visible after it has been approved.

    Насос скважинный “Vodotok” БЦПЭ-Н-100-0,5-170м – Предназначение: Модели насосов серии БЦПЭ-Н предназначены для перекачивания только чистой воды из колодцев, резервуаров, скважин, для использования в гражданских и индустриальных областях, садоводстве поливе и т. д. Насосы моделей БЦПЭ-Н имеют рабочие колеса, корпус, крыльчатку, вал, корпус мотора, сетчатый фильтр, диффузор из нержавеющей стали марки AISI 304 SS. Комплектация: Насос в сборе – 1 шт. Руководство по эксплуатации – 1 шт. Гарантийный талон – 1 шт. Упаковка – 1 шт. *Производитель имеет право изменять вышеуказанную комплектацию.Насос скважинный “Vodotok” БЦПЭ-Н-100-0,5-170м
    Насосы здесь –
    насос для скважины 20 метров,
    вихревой насос для скважины,
    замена насоса в скважине эцв,
    насос для скважины поверхностный для дачи,
    насос нефтяной скважины.

Leave a Reply

Your email address will not be published. Required fields are marked *

(Your message will only be visible after moderation)