Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Gecko in C#

I need a Gecko WebBrowser Control

I need a sample code or a link which explains how to use GECKO

If anyone has used Gecko, I could do with some advice

like image 667
DanMatlin Avatar asked Jan 08 '12 14:01

DanMatlin


People also ask

What is Gecko in computer?

Gecko is the layout engine developed by the Mozilla Project and used in many apps/devices, including Firefox and Firefox OS. Web browsers need software called a layout engine to interpret HTML, CSS, JavaScript, and embedded content (like images) and draw everything to your screen.

What is GeckoFX?

GeckoFX is a Windows Forms control written in clean, commented C# that embeds the Mozilla Gecko browser control in any Windows Forms Application. It also contains a simple class model providing access to the HTML and CSS DOM.


2 Answers

Original tutorial with detailed snapshots can be found here.

A most recent update can be found here. Please upvote in that article if you find it useful :)

To embed Gecko browser in your winform application, you need:

  • XulRunner: XULRunner is a Mozilla runtime package that can be used to bootstrap XUL+XPCOM applications that are as rich as Firefox and Thunderbird. It provides mechanisms for installing, upgrading, and uninstalling these applications. XULRunner can be downloaded here. Choose the version you like.
  • GeckoFx .net assembly file, which you can download from here. Also choose the correct version which matches the XulRunner version.

  • Unpack the GeckoFX-330.zip, you will get below files:

enter image description here

  • Add references to the dlls as shown above, click browse and select the Geckofx-Core.dll and Geckofx-Winforms.dll

enter image description here enter image description here

  • In the toolbox, right click, and then select “Choose Item”, select Geckofx-Winforms.dll, and the Gecko winform control will be shown in the toolbox

enter image description here enter image description here

  • Drag a GeckoWebBrowser control to the winform designer, and let’s call it “browser” enter image description here

  • In the form1.cs file, add below code: enter image description here

The line Gecko.Xpcom.Initialize(@”..\xulrunner”); specifies where the xulrunner runtime is located. In this case, we put it into a folder (@”..\xulrunner”).

Now run the application, yeah~~~

enter image description here

like image 99
David Avatar answered Nov 15 '22 22:11

David


You should check out http://code.google.com/p/geckofx/. To get some code samples see the Wiki page.

like image 23
Johnny Graber Avatar answered Nov 15 '22 22:11

Johnny Graber