Using Skybound GeckoFX with Xul Runner on C#

skybound geckofx instead of iexplore

If you want to integrate Internet Explorer browser into a C# application you may have problems if you access sites vis SSL and other facilities. So, I would recommend instead of IE to use Skybound GeckFX with Xul Runner which will help you to integrate Firefox Browser into your C# Application.

How to Add Skybound GeckoFX Browser To C# Applications:

#1. Downloading the following resources:

  1. GeckoFX Wrapper -> Download Here
  2. Xul Runner -> Download Here

Full Archive used by me in this tutorial with booth GeckFx and Xul Runner: Download Here

#2. UnRar the files into C:\Libs\C#\SuperGecko

#3. Adding GeckoFX dependencies on C#:

Go to Solution Explorer >> Right-Click on Project_Name >> Add >> Reference… . >> Browse >> Click on Browse Button and select C:\Libs\C#\SuperGecko\Skybound.Gecko\bin\Releas\Skybound.Gecko.dll assuming that you uncompressed downloaded archive inside the folder I’ve said above;

#4: Configuring C# Application to use GeckoFX WebBrowser:

Your project should begin with this code:

 public Form1()
 {
    InitializeComponent();
 }
 

Replace it with:

 public Form1()
 {
    InitializeComponent();
    Skybound.Gecko.Xpcom.Initialize(@"C:\Libs\C#\SuperGecko\xulrunner-1.9.1.11.en-US.win32\xulrunner");
    GeckoPreferences.User["security.warn_viewing_mixed"] = false;
    GeckoPreferences.User["plugin.state.flash"] = 0;
 }
 

Now that’s all with dependencies.

How to use GeckoFx Web Browser on C# Application:

First of all don’t forget to add namespace at the begin of program:

    using Skybound.Gecko;
    using Skybound.Gecko.DOM;

Now we can start using GeckoFX WebBrowser.

Adding WebBrowser on C# Application Visual Form:

Go to Form1.cs[Design] and then Right-Click on any Item from ToolBox >> Choose items… :

adding geckoFX into c#

Now insert gecko in search field >> Double-Click on result >> Click OK Button:

geckofx on c# application

That’s not all. Now you will find GeckoWebBrowser on Toolbox:

gecko webbrowser on toolbox c#

Now you can add it into your C# Form Application.

GeckoFX Web Browser – Tips & Tricks:

If you want to auto complete some fields on button click which looks like:

<input type="text" id="email" name="email">
<input id="password" type="password" name="password">

and then Submit these information you may do it in this way:

private void button2_Click(object sender, EventArgs e)
{
    try
    {
        GeckoInputElement username = new GeckoInputElement(browser.Document.GetElementsByName("email")[0].DomObject);
        username.Value = "YourEMAIL";
        GeckoInputElement password = new GeckoInputElement(browser.Document.GetElementsByName("password")[0].DomObject);
        password.Value = "YourPassword";
        browser.Navigate("javascript:void(document.forms[0].submit())");
    }
    catch (Exception ex)
   {
       Console.WriteLine(ex.ToString());
   }
}

You can find many more examples on internet 🙂

Conclusions:

You know now how to use GeckoFX WebBrowser (Firefox) instead of Internet Explorer Browser integrated into your C# Application.

Related posts:

One Comment on "Using Skybound GeckoFX with Xul Runner on C#"

  1. Rangga says:

    i use GeckoFX in my VB.net application. ( VS2013 project ). There is no download events in this browser control. When you click on page that have a download link item, and nothing happen. This control doesnt trigger download..Some thing missing with this control or maybe i dont know how to use it.

Got something to say? Go for it!