c# Using GeckoFx 14 How to get started?

David Eaton picture David Eaton · Sep 12, 2012 · Viewed 13.3k times · Source

I am looking at this site : https://bitbucket.org/geckofx/geckofx-14.0

I don't know anything about GeckOFX, so downloading the the zip file I make references to Geckofx-core-14 and Geckofx-WinForms-14.

I use the this code...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Gecko;
using GeckoFX;

namespace GeckoFXTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            //Gecko.Xpcom.Initialize("C:\\tools\\xulrunner");
            GeckoWebBrowser myBrowser = new GeckoWebBrowser();
            this.Controls.Add(myBrowser);
            myBrowser.Dock = DockStyle.Fill;

            myBrowser.Navigate("http://www.google.com");
        }
    }
}

But I think I am missing something, can someone tell me what I am missing? OR how to get started, I can't find docks for GeckOFX 14

Using C# WinForms 4.0 .Net Thanks in Advance.

Answer

Tom picture Tom · Sep 13, 2012

The line you have commented out is important:

//Gecko.Xpcom.Initialize("C:\\tools\\xulrunner");

You need to download xulrunner 14 or firefox 14 and tell geckofx where to find it, by calling Gecko.Xpcom.Initialze before creating the GeckoWebBrowser control.

Also you only need to call Xpcom.Initialize once per application so you prolly don't want to put it in your Form Constructor.