Embeding Firefox Brower (Gecko Engine) in C# using GeckoFX

Ever Thought if it was possible to not WebBrower control and use the Firefox Browser in your c# window Application…??

Yes ,, It is possible using GeckoFx wrapper class for  C#.net and vb also.

You will need the Followings:

1. GeckoFx Wrapper [Download]
2. Xul Runner [Download] (Download the zip file from here)

How to:

1.   Now Extract Skybound.GeckoFX.bin.v1.9.1.0.zip (First download).
      You will find Skybound.Gecko.dll and that’s what we need.
2.   Now create a Project and name is GeckoFxcsharpBorwer or anything you like.
3.   Now  add the reference of the above dll and also add that to your toolbox.
4.   Now Exctract the Second downloaded file (xulrunner-1.9.1.2.en-US.win32.zip). and you will find xulrunner . This is the path to xulrunner runtime.
5.   Create a Form Layout Like The Figure Below:

Now The Coding Part:

Our Form’s Constructor:(Providing the Path to XulRunner Runtime)

public Form1()
{
InitializeComponent();
Skybound.Gecko.Xpcom.Initialize("Path To the xulrunner directory [Extracted from the Second Downloaded File]"); // for example "c:\xulrunner\"
}

Form’s Load Event:

private void Form1_Load(object sender, EventArgs e)
{
geckoWebBrowser1.Navigate("www.google.com");
}

Stop Button click Event:

private void btnStop_Click(object sender, EventArgs e)
{
geckoWebBrowser1.Stop();
}

Refresh Button Click Event:

private void btnRefresh_Click(object sender, EventArgs e)
{
geckoWebBrowser1.Refresh();
}

Save Page Button Click Event:

private void btnSavePage_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = " Html File | *.html";
if (sfd.ShowDialog() == DialogResult.OK)
{
geckoWebBrowser1.SaveDocument(sfd.FileName);
}
}

And Now Finally the Output:

That’s All.

Complete Project : GeckoNet

ps: You can easily Add an Addressbar and other stuff

 

23 thoughts on “Embeding Firefox Brower (Gecko Engine) in C# using GeckoFX

  1. @Phillip Bismonte : Adding reference is easy. Find the references in your Visual Studio Solution Explorere. Right click and add Reference. Choose the DLL.

  2. @Marco Pagaroli: Adding reference is easy. Find the references in your Visual Studio Solution Explorere. Right click and add Reference. Choose the DLL.

  3. For Adding to Toolbox , Right click anywhere on ToolBox panel and select "Choose Items" -> Go to .NET Frame work component -> Browse for the DLL file and you will find the "GeckoWebBrowser" component.

    Click OK

  4. thanks sir…can u help me for update fx , this working but i want to upgrade version…if have any opetion please share with all reader….i thing it's help full question all adv programmer

Leave a Reply

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