Help with Gecko

MrDot->"."

New member
Joined
Jan 16, 2010
Messages
3
Programming Experience
Beginner
Hi. I'm a Beginner and I am trying to make a simple web browser in Visual Basic 2008 (with Visual Studio 2008 Professional Edition) that uses the Gecko engine via a tool called GeckoFX and the XULrunner's dll's and resources.

About GeckoFX - geckofx - Project Hosting on Google Code

The book I am learning VB with hasn't covered this aspect yet but I almost have it all set up - this is just a side project I decided to play with because it looked really easy.

The Problem:

"
(2) In your application startup code, call:

Skybound.Gecko.Xpcom.Initialize(xulrunnerPath);

where "xulrunnerPath" is the full path to the location where you extracted the "xulrunner" directory
(containing xul.dll, xpcom.dll, etc)."


How do I do this?

So you will understand what I did do, here are the full (short) instructions.


"Getting Started
---------------
GeckoFX is a .NET wrapper around XULRunner, a runtime based on the same source
code as Firefox. You can add the control to your windows forms app and use it much the
same way as System.Windows.Forms.WebBrowser.

Since GeckoFX is a wrapper, you need to have the XULRunner runtime somewhere on your
development system (and redistribute it with your application). GeckoFX now works best
with XULRunner 1.9.1 (Firefox 3.5).

(1) Download XULRunner 1.9.1 from:

http://releases.mozilla.org/pub/moz....2/runtimes/xulrunner-1.9.1.2.en-US.win32.zip

(2) In your application startup code, call:

Skybound.Gecko.Xpcom.Initialize(xulrunnerPath);

where "xulrunnerPath" is the full path to the location where you extracted the "xulrunner" directory
(containing xul.dll, xpcom.dll, etc)."

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have downloaded both the GeckoFX package and the XULrunner package and unzipped them and placed the GeckoFX folder and the XULrunner folder in C drive.

I have right clicked Choose Item in the toolbar and chosen the GeckoWebBrowser control to use in my form app.

I know the path to the XULrunner runtime is C:\xulrunner

My browser only has the windows form with a text box, a button and the GeckoWebBrowser control.

Now I need to set the call for the uxlrunner startup path where it needs to be. I have read that if I right click the project in Solution Explorer, I should see this option under properties.. but I do not see anyplace to do this or I just am not getting it. Please help a newbie out.

Thanks!

(of course I could just wait till the book caught up with this but what's the fun in that?)
 
Last edited:
Go to code view (menu View > Code, or press F7, or double-click the form). In form code write "Public Sub New" and press Enter. Where it says "' Add any initialization" add the code:
VB.NET:
Skybound.Gecko.Xpcom.Initialize("C:\xulrunner")
 
Go to code view (menu View > Code, or press F7, or double-click the form). In form code write "Public Sub New" and press Enter. Where it says "' Add any initialization" add the code:
VB.NET:
Skybound.Gecko.Xpcom.Initialize("C:\xulrunner")

Excellent! That worked for inputting the code.. Now I know. But.. I am getting an error on debugging and running that which says,

"An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load file or assembly 'Skybound.Gecko, Version=1.9.1.0, Culture=neutral, PublicKeyToken=3209ac31600d1857' or one of its dependencies. An attempt was made to load a program with an incorrect format."

I do not think this is any fault of Visual Basic. I suppose I will have to try to get answers for this out of the people who made the GeckoFX.

Thanks though ! At least I learned something. :)
 
Last edited:
I just did a short test, just like you, added the GeckoWebBrowser to Toolbox and dragged one to form, added the Initialize call, then I used a Navigate call to load a webpage. I encountered no problems with this.

One problem I did find was if there were additional ActiveX controls on the form, then I needed to call Initialize before InitializeComponent, else I got the "could not find XULrunner" error message regardless. There is also a Application.StartUp event that can be used, this is called before any form is created.
 
I just did a short test, just like you, added the GeckoWebBrowser to Toolbox and dragged one to form, added the Initialize call, then I used a Navigate call to load a webpage. I encountered no problems with this.

One problem I did find was if there were additional ActiveX controls on the form, then I needed to call Initialize before InitializeComponent, else I got the "could not find XULrunner" error message regardless. There is also a Application.StartUp event that can be used, this is called before any form is created.

Oh wow.. that's very interesting.. did you actually get it to run and surf with it?

Here is my code:
VB.NET:
 Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GeckoWebBrowser1.Navigate(TextBox1.Text)

    End Sub
    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        Skybound.Gecko.Xpcom.Initialize("C:\xulrunner")


        ' Add any initialization after the InitializeComponent() call.

    End Sub
End Class

Does this look fine to you?

Only other thing I can think of it's a 32 bit code only.. I have to change my build settings to 32 before I build it because i am on a 64 bit os.. I do not remember now if I did that or not..I will look and see. Are you on a 32 bit os?

EDIT: I just checked.. I remember now I did not tell VS to use 32 bit because I could not find it.. in my projects properties instead of Build I see Compile.. I dont have the option to change the output build that I can find.

Why do I see Compile instead of Build?

Edit2: I just changed the build manually in .proj to x86 instead of AnyCPU and I still got the same error.
 
Last edited:
MrDot->"." said:
Oh wow.. that's very interesting.. did you actually get it to run and surf with it?
JohnH said:
I used a Navigate call to load a webpage. I encountered no problems with this.
MrDot->"." said:
Only other thing I can think of it's a 32 bit code only.. I have to change my build settings to 32 before I build it because i am on a 64 bit os.. I do not remember now if I did that or not..I will look and see. Are you on a 32 bit os?
Yes I am. Yes, this is a likely solution, the xulrunner libraries does say they're 32bit.
I just checked.. I remember now I did not tell VS to use 32 bit because I could not find it.. in my projects properties instead of Build I see Compile.. I dont have the option to change the output build that I can find.
See thread http://www.vbdotnetforums.com/vb-net-general-discussion/37359-compile-64bit.html about Configuration Manager settings.
 
Back
Top