Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[TUT]The Implementation of GeckoFX[TUT]

The Implementation of GeckoFX

This tutorial is going to show you how to implement GeckoFX (the web browser control) into your own VB.NET program so that you don't have to use the hated default IE one. Let's begin.

What you need:
  • GeckoFX files - Download
  • XUL Runner Files - Download
  • VB.NET Project Already Coded - Download
    -NOTE: XP SP3 and IE7/8 have an error not mentioned in the tutorial because it was written in Win7. It has to do with your operating system. Sorry!

Step 1.
Open up your new VB.NET project and name it whatever you would like. Now put a menustrip in your project, and name the first one Start, and the second one Exit.
Spoiler (Click to View)
Save the project whatever you like.

Step 2.
Put the entire xulrunner folder after it is extracted into the debug folder also. Make sure all the xulrunner files are one level into the xulrunner folder.
Spoiler (Click to View)

Step 3.
In Solution Explorer, right click on your project name and click "Add Reference". Click "Browse" and navigate to where you put Skybound.Gecko.dll. Click it. Click okay.
Spoiler (Click to View)

Step 4.
Put the following code in Form1:
Code
'**
'*    *
'* Author: RK  *
'* Example provider: ident    *
'*    *
'* Contact: [email protected]    *
'*    *
'* DESCRIPTION    *
'*    *
'* Implements Gecko engine.  *
'*    *
'**

Option Strict On

Public Class MainForm
    Private Sub StartToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartToolStripMenuItem.Click
  MessageBox.Show("Give it a few seconds to load up the webpage.")
  GeckoWebBrowser1.Navigate("https://hackforums.net")
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
  Me.Dispose()
    End Sub
End Class

'IMPLENTATION NOTES:
'
' 1) http://en.wikipedia.org/wiki/Gecko_%28layout_engine%29
' 2) http://releases.mozilla.org/pub/mozilla.org/xulrunner/releases/

Step 5.
In your project toolbox you should see GeckoWebBrowser at the bottom of all your tools. Drag it onto your project. Set it's dock to "Fill".
Spoiler (Click to View)

Step 6.
In Solution Explorer, right click and then click on "Add". Add a Code File named "Application Events.vb."
Spoiler (Click to View)

Step 7.
Add the following code to ApplicationEvents.vb:
Code
Imports System.IO
Imports Skybound.Gecko

Namespace My

    ' The following events are available for MyApplication:
    '
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication

  Protected Overrides Function OnStartup(ByVal eventArgs As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) As Boolean

    Dim ProfileDirectory As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\xulrunner\DefaultProfile"

    If Not Directory.Exists(ProfileDirectory) Then
    Directory.CreateDirectory(ProfileDirectory)
    End If
    Xpcom.ProfileDirectory = ProfileDirectory

    Dim xrPath As String = System.Reflection.Assembly.GetExecutingAssembly.Location
    xrPath = xrPath.Substring(0, xrPath.LastIndexOf("\") + 1) & "\xulrunner"
    Xpcom.Initialize(xrPath)

    Return True
  End Function

    End Class

End Namespace
Save EVERYTHING
Spoiler (Click to View)

Step 8.
Debug the project. It should work perfectly now.
Spoiler (Click to View)

Step 9.
Post a reply on this thread what you thought of my tutorial! I put a lot of time and effort into writing this trying to help you figure out how to implement GeckoFX into your VB.NET application. The least you can do is post a reply that takes a few seconds to write in order to keep the thread alive. Credit for this tutorial goes to me, eXero. Ident helped with some things. Thank you for reading!
Awesome! Gonna try this, thanks!
Nice, this should help others easily implement gecko to their projects :)
Thanks for the replies guys! I appreciate them.
You finally sussed it out then ;D
nice tutorial :)
Awesome tutorial, I know this will help me in the future.
Haha Welcome Cody8295 and yeah ViolentReality.
Maybe peoples will stop use the WebBrowser control provided by VS and use this instead.

Good tutorial, keep it up :)
Thank you BaussHacker. I appreciate the replies everyone! Please post a reply to keep the thread alive!
Unable to load DLL 'xpcom': The specified procedure could not be found. (Exception from HRESULT: 0x8007007F)

I tried this method but it won't work. The only way I can get it to work is by having the entire contents of xulrunner in debug instead of having a nice organized folder which is a pain in the ass.
very nice tutorial thank you for the share
(Apr 25, 2011 10:18 AM)Entangled Wrote:  Unable to load DLL 'xpcom': The specified procedure could not be found. (Exception from HRESULT: 0x8007007F)

I tried this method but it won't work. The only way I can get it to work is by having the entire contents of xulrunner in debug instead of having a nice organized folder which is a pain in the ass.

you need to import the folders contents
The xulrunner folder needs to be in debug.
It is in there. I even tried it with YOUR project that you put up as an example (I do have a working one, but it's really ugly having the entire XULRunner folder's contents everywhere the application is...) to see if it was just my project. Your project gave me the same error. I did some searching and apparently it's a problem with XP SP3/ IE7/8. I think what happens is in XP, it finds the XPCOM.dll, but after it's found it keeps trying to load other DLL's. (This is simply what I found on Gecko's website.) If I upgraded to Win 7 then it probably wouldn't be a problem. I'm still not too sure on the entire situation, however.
Is it like if we're using Firefox but on our VB.Net forms?


Possibly Related Threads...
Thread / Author Replies Views Last Post
by putnik1313May 26, 2025 03:04 PM 6 224 May 26, 2025 03:04 PM
Last Post: putnik1313
[Python] by mikehackMay 9, 2022 11:12 AM 2 151 May 9, 2022 11:12 AM
Last Post: mikehack
[Python] by omar18881Feb 13, 2022 09:02 PM 3 218 Feb 13, 2022 09:02 PM
Last Post: Security Is 1776