# VBForums CodeBank > CodeBank - Visual Basic .NET >  Mozilla / Firefox / Gecko in VB.NET

## Radjesh Klauke

Here's a very easy to follow tutorial how to implement the Firefox/Gecko plugin within Visual Studio and use it as an IE replacement. _It's faster and safer and better then the IE component and no IE or other browser needed on the client-computer to make it work._

These are only the very basics to make it work.

========================================================

1) Download and extract: http://releases.mozilla.org/pub/mozi...n-US.win32.zip
Within the extracted folder You find a folder with the name "xulrunner"

2) Drag the  whole folder (including sub-folders and files) to your solution explorer;

3) Now, *every file!* within the xulrunner-folder need to be *Copy To Output Dir* -> *Copy if Newer*



4) Download and extract: http://geckofx.googlecode.com/files/...n.v1.9.1.0.zip

5) Cut/copy the file "Skybound.Gecko.dll" from the bin-folder and place it where ever you want. There is no need for the rest so you can throw that away.

6) Now you need to add the "Skybound.Gecko.dll" to your toolbox.
    - right-click the "Toolbox" and select "Choose Items...";
    - click "browse" in the ".NET Frameworks components" Tab;
    - search for the Skybound.Gecko.dll and press OK; (GeckoWebbrowser appears, see image below. I created a new tab for the component. You can do that also.)



Now we can do stuff:

7) Add the component and a button to your Form;

*UPDATED 25-03-2011*
-------------------------------------------------------------
8) Open the properties of your application;
9) Click on "View Application Events" in the "Application"-tab;

Copy and past the following:



```
Imports Skybound.Gecko
Imports System.IO

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.LocalApplicationData) & "\subfolder\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) & "\subfolder\xulrunner"
            Xpcom.Initialize(xrPath)

            Return True
        End Function
    End Class
End Namespace
```

You can change the name and path of the folder like you want it to be. This means you can also change the name "xulrunner"

-------------------------------------------------------------

10) Copy and paste the following code into your Form and run:



```
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    GeckoWebBrowser1.Navigate("http://www.radjesh.nl")
End Sub
```

==================================
http://www.mediafire.com/?9s95u1ex9zj4q19   <<< Download example (7MB (.rar))
==================================


That's it._Happy Coding and God Bless_  :Thumb:

----------


## v7web

Hi,
I have been looking for a way to do this for ages.
I have followed your instructions but every time I try and run the program I get an error box with the following:

network39
However when I check the location the xulrunner folder and files are all there.

----------


## Radjesh Klauke

Hmmm... That is really weird. You did call the Initialize component in the Form_load? You are sure that you have copied all the files? Make sure you did.



```
Skybound.Gecko.Xpcom.Initialize(Application.StartupPath & "\xulrunner\")
```

----------


## v7web

> Hmmm... That is really weird. You did call the Initialize component in the Form_load? You are sure that you have copied all the files? Make sure you did.
> 
> 
> 
> ```
> Skybound.Gecko.Xpcom.Initialize(Application.StartupPath & "\xulrunner\")
> ```


Hi,
Yes I initialized the code in Form_Load and all files are copied to location.
I am banging my head against the wall here, I really want to use this but just cant see why the files are not being recognised.

Here is a screenshot of my explorer, as you can see the folder has been copied to output (debug) with no problems and all the files/folders are there.

[Removed by moderator]

----------


## Radjesh Klauke

Ok.... try this:

Drag all the files and folders *out of the xulrunner-folder* in your solution explorer to your project and recode:


```
Skybound.Gecko.Xpcom.Initialize(Application.StartupPath)
```

So no file should be in the "xulrunner" folder anymore. Tell me if it worked, so I'll change the tuto above. This is still very strange behavior, 'cause it works fine in my current project, but in a new project I got the same error. The solution above worked for me. Yet, very, very, very strange...  :EEK!:  :EEK!:  :EEK!:  :Sick:  :Ehh:

----------


## v7web

Thanks Radjesh Klauke
I moved files directly into project solution and changed initial call to:

vb Code:
Skybound.Gecko.Xpcom.Initialize(Application.StartupPath)

All works great now.

Many thanks

----------


## Radjesh Klauke

Great to hear. I will adjust the tuto.

----------


## SirPereira

What are the methods from this API ?  :Smilie:

----------


## Radjesh Klauke

Have a look at: http://geckofx.org/  :Wink:

----------


## dewshare

Thanks for sharing can you tell me which is ProgressChanged Event in it  ?? there is no ProgressChanged any alternative in this.

also tell me if I delete IE and Firefox did my project work now ??

----------


## softwareguy74

Very interesting if this actually works.  Does it also include the JavaScript engine, not just the HTML rendering?

----------


## reconrey

is there a faster way to do this: Copy To Output Dir -> Copy if Newer

----------


## reconrey

i noticed that when playing youtube videos in this browser the volume is extremely low...(i played the same videos in chrome and it was regular loud) Can i fix this?

----------


## Radjesh Klauke

Sorry for the late reply, but I really don't know. Try to ask that on the forum of GeckoFX.

----------


## dewshare

I am unable to show Context Menu in Gecko Web browser. Also i don't find any help on Geckofx forum. Please any one here can solve my problem. is there any why to show context menu 

i am using xurlrunner 1.9.1

----------


## Radjesh Klauke

You didn't search: http://geckofx.org/viewtopic.php?id=595
Register and ask there.

----------


## dewshare

i have asked there many time and also related threads are there but no solution !!!

Plz......

----------


## Radjesh Klauke

This is not the place to ask for help regarding the dll itself. This only shows how to implement it.

----------


## Knvn

> Thanks for sharing can you tell me which is ProgressChanged Event in it  ?? there is no ProgressChanged any alternative in this.
> 
> also tell me if I delete IE and Firefox did my project work now ??


Try this:



```
    Private Sub Browser_ProgressChanged(ByVal sender As Object, ByVal e As Skybound.Gecko.GeckoProgressEventArgs) Handles Browser.ProgressChanged
        ToolStripProgressBar1.Maximum = e.MaximumProgress
        ToolStripProgressBar1.Value = e.CurrentProgress
    End Sub
```

----------


## GreyWolf

Hi there.  :wave: 

I hope you can help me.  I have no problem in initializing the program and do not get any nasty messages.  However, when the form comes up, it doesn't do anything even if I push the button.  Using the following command:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        GeckoWebBrowser1.Navigate("http://www.comcast.net")

    End Sub

Thank you.

----------


## Radjesh Klauke

That's weird, but your button_code isn't correct. It should be:


```
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
```

What code do you have in the Form_Load?

----------


## GreyWolf

Thanks.  That Handled the problem.  I am a Bone Brain sometimes.

----------


## Aeromonasoft

Hi
I'm kind of new to this whole 'gecko' usage - but I attempted to use it in my project in Visual Basic 2008 (Express Edition) and it keeps turning up this same error...

Error	1	"chrome\classic.manifest;chrome\comm.manifest;chrome\en-US.manifest;chrome\pippki.manifest;chrome\toolkit.manifest;Microsoft.VC80.CRT.manifest" is an invalid value for the "InputManifest" parameter of the "GenerateApplicationManifest" task. Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem".	GeckoBrowser

I have not edited any of the files they have provided and I am currently using Windows XP with .NET framework 4 and 3.5 SP1 installed...

If someone could please help me out - It would be much appreciated...

----------


## Radjesh Klauke

Means that you didn't do as the tutorial said.
To be sure: Create a new project and follow the tutorial again.

----------


## Aeromonasoft

Thank you for replying so soon...  :Smilie: 
But although I tried it multiple times each time in new projects, the same error comes up...
I even tried another project: http://www.planet-source-code.com/vb...20109162039576
But still, when I try to publish the project, the error turns up (ONLY when I try to publish... I can run it fine... But cannot publish...)
Thanks for your help in advance...

----------


## Radjesh Klauke

Does this also occur during debugging?
Can you upload the project without any .exe?

----------


## Aeromonasoft

Actually, no - the error only appears after I've tried to publish it... Debugging works fine... And as I said - I've tried it with some other projects which use Gecko as well - and they all work fine, until I try to publish it of course...
The files seemed too big to upload here - so here's a link:

http://www.4shared.com/file/hQ0IzXvq/GeckoBrowser.html
 :Smilie:

----------


## Radjesh Klauke

??? I need to pay to download....
Are you kidding me? I won't help you anymore!

----------


## Aeromonasoft

Really sorry...
But no - you don't have to pay actually - you just have to wait 30 seconds and it gives the download link, I didn't know where else to upload the file...  :Frown: 
Anyways... It's alright if you are too busy - I'm using the internet explorer component for now...

----------


## Radjesh Klauke

use: http://www.mediafire.com/

----------


## Radjesh Klauke

Updated the tutorial. Now you can add the full folder to your project and give the folder the name you want and place it where ever you want. Make sure you change the path (and name) of the folder in the ApplicationEvents.vb.

----------


## crazy1993

I don't know what i did wrong but everything is were it should and such. I added GeckoWebBrowser1.navigate("http://www.google.com") to a button click event and when i click the button it makes an error and acts as though it was null. Can u help me with this? i am trying to implement gecko into an existing project. It is a new form though.

[ERROR LOG REMOVED TO SAVE SPACE]

----------


## Radjesh Klauke

I don't know what you have done so I can't help you with the info you provided.
You should provide code.

----------


## crazy1993

So silly of me. My bad.

AppilicationEvents.vb

vb Code:
Imports Skybound.GeckoImports System.IO Namespace My         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.LocalApplicationData) & _                "\MY COMPANY\MY APPLICATION\DefaultProfile"            If Not System.IO.File.Exists(ProfileDirectory) Then                System.IO.Directory.CreateDirectory(ProfileDirectory)            End If            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 ClassEnd Namespace

Form_Browser.vb

vb Code:
Public Class Form_Browser     Private Sub Form_Browser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load     End Sub     Private Sub ButtonGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGo.Click        GeckoWebBrowser1.Navigate("http://google.com")    End SubEnd Class

My error occurs when I click the button to navigate. When i press F5 to start debugging i don't get the message box that says it did not find xulrunner so I am not sure what my problem

----------


## Radjesh Klauke

You didn't change the paths. besides that.... it isn't the code I provided... :s

----------


## Radjesh Klauke

I've created an example. The downloadlink can be found in the original post.

----------


## crazy1993

Thanks for the example but things still are not working when I copy it to my own program. I copied the gecko dll u use and the xulrunner. It works fine in yours but not mine. I uploaded it to my website, if you have time could you take a look? Appreciate it.

URL REMOVED - NO LONGER VALID

----------


## Radjesh Klauke

The url you provided isn't valid. Please check things. I have more to do.

----------


## crazy1993

Link Fixed. It prob didn't work cuz i didn't make it a link i just typed it out. I was on my iphone and class was about to start. Sorry about that. Thanks for your time!

LINK REMOVED - NO LONGER VALID

----------


## Radjesh Klauke

Sorry, but I can't test your app. I'm getting loads of errors when I try to debug it. I suggest you create a new project yourself and first test if it works.

----------


## crazy1993

Curious, what kinda errors are you getting? I do not get any errors nor does a friend when he has the project. I am bettin they are prob path errors that you need to change to match your system and where you saved the project. In either way, I will try removing as much as possible from the project and reimpose it. I do have some images and stuff that may be the root of the problem. I will also try creating a new project and trying the steps again. Thank you for your time.

----------


## crazy1993

I am not sure entirely what I did but i managed to get it to work. I think it may have been due to the reason that i forgot to copy to output dir. i copied it to the bin/debug folder by hand since their are so many files to go through and changer. it worked! This is a great tutorial too. Thanks for taking the time to try and help me. +Rep 4u

----------


## oligono

Hello

I would get the text (or source) of a website, but I can't.

I use this in VB.Net 2008:



```
Dim x As String = GeckoWebBrowser1.Document.DocumentElement.InnerHtml
```

(similar to   WebBrowser1.DocumentText)

But that doesn't work. x returns nothing (the site is fully charged in GeckoWebBrowser1)

Any suggestions?

Thanks and sorry for my English

----------


## Radjesh Klauke

If that doesn't work, then why didn't you search Google? http://forums.techarena.in/software-...nt/1157315.htm

----------


## oligono

Thanks for your answer, Radjesh Klauke
I've searched but I haven't found.
I have no problem if I create a WebBrowser (Internet Explorer). I can use 


```
WebBrowser1.DocumentText
```

My problems are with GeckoWebBrowser (Mozilla Firefox) and in that site they don´t use GeckoWebBrowser
Thanks anyway and I'm sorry for my English again

----------


## Radjesh Klauke

try asking on the original forum of the component  :Wink: 
http://www.geckofx.org/

----------


## hirenlad

Hiii Radjesh Klauke,

      Hey, i m downloaded your application... and used it in new windows application in Visual studio 2010. but i m faced below error when i run this application.. 

      "Specified cast is not valid."

   can u please help me... ?

 - Hiren Lad

----------


## Radjesh Klauke

hmmm.... can you upload the project without the exe files?

----------


## zeeshanstudent

I want to use different proxies on gecko browser can any one told me its code or api???

----------


## Radjesh Klauke

Have a look at this: http://www.geckofx.org/viewtopic.php?id=1205
Perhaps that's helpful.

----------


## vgopalap

Can any one tell me how to add a download manager to my tabbed gecko browser. Tried most of the options but still not able to get it work.

----------


## Sega dude

Is there any way to print from this? .Print and .ShowPrintDialog don't work.

----------


## Radjesh Klauke

Go to the forum of the creator(s). I'm only showing you how to implement it.

----------


## jalexander

Has anyone successfully implemented this in projects they had previously coded with IE web controls?
And does anyone have/or know where to find the "DOM CLASSES" mentioned in the 2nd post within this thread http://www.geckofx.org/viewtopic.php?id=1378

They are what's needed for a more IE style interface with the pages, i.e. setting forms etc. & all the basic things easy to do in the IE control.

I would SERIOUSLY appreciate anyone that can help me find these. As the 'search feature' on geckofx.org is down & has been down for weeks now. Making it virtually impossible for me to put the time in to find the said files!

Thanks
- Jennifer Alexander <3

----------


## Radjesh Klauke

You can use this besides the IE controls. Don't know where to find the DOM classes btw.

----------


## zeeshanstudent

can any one guide me how to pass list of IP addresses to Gecko browser because i want to implement a boot by using Gecko browser kindly help we i shall be very thankfull to you.....!!!!

----------


## Radjesh Klauke

Ask on the forum of the .dll.

----------


## DJFireCFR

hi guys, Sorry to update an old thread, but this was the best thread I could find after search for 3 days of an error I "was" getting.  But after following the short tutorial on this thread, I was able to get past the original error I was getting, but now I got a new one. which is the following:

"System.InvalidCastException: Specified cast is not valid." Below that has 


```
   at Skybound.Gecko.nsIWebBrowser.GetContentDOMWindow()
   at Skybound.Gecko.GeckoWebBrowser.OnHandleCreated(EventArgs e)
   at System.Windows.Forms.Control.WmCreate(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at Skybound.Gecko.GeckoWebBrowser.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
```

I have followed all the steps listed, including making all the files in the xulrunner folder "Copy if newer"

So then what I tried was saving that, then closing the project, and created a new project, followed all the steps over again... and now I get this error when trying to publish:


```
Error	1	"xulrunner\chrome\classic.manifest;xulrunner\chrome\comm.manifest;xulrunner\chrome\en-US.manifest;xulrunner\chrome\pippki.manifest;xulrunner\chrome\toolkit.manifest" is an invalid value for the "InputManifest" parameter of the "GenerateApplicationManifest" task. Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem".
```

So either way, now im getting 2 separate errors on 2 different projects.  can someone help me out a bit with this?  Either Project will be fine,  Once I get past the error, I can continue with my original project.  I just need to find out why im getting either of those 2 errors. So im hoping the original poster here, still visits this forum.  :Big Grin:

----------


## Radjesh Klauke

This version is a bit deprecated. I will create a new thread as soon as I have some more time, 'cause the new and better dll is from another developer.
But there is also the issue that you aren't telling what you did exactly.



> Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem"


Why did you create multiple items? Perhaps you can upload your project?

----------


## DJFireCFR

Im not exactly sure what multiple Items I created... The 2nd project with that error was a completely new  project

Here is a link to a zip file with Screen shots in it from each part.. ApplicationEvents, Form1, Form1.Design, and Solution Explorer.  If you need the actual files themselves, I will upload those in a rar file, cause its actually a bit big.
http://www.crossfire-radio.com/test/vb/Files.zip

Oh and .. Thank you so much for replying.

----------


## Radjesh Klauke

Give me some time to create a new tutorial with Firefox/Gecko Engine 13.

----------


## DJFireCFR

Just a quick note... I am using the following: 
Skybound.Gecko.dll v1.9.1.0
xulrunner v1.9.2

----------


## jalexander

> Give me some time to create a new tutorial with Firefox/Gecko Engine 13.


I think everyone will be looking forward to that! I for one canno't stand the IE webbrowser control....just not enough options to code things down to the smallest details ya know?
Sure hope you get around to it :-)  And thanks so much for your contribution to all of us forum peeps!

----------


## DJFireCFR

> Give me some time to create a new tutorial with Firefox/Gecko Engine 13.


hey there Radjesh, was just checking in to see how things were going.. im pretty sure you have a very active / busy life going on outside of here, but seeing if you were able to get anywhere yet

----------


## Radjesh Klauke

Nope, not yet, sorry. This week I have to do something for a good friend. Probably, next week  :Wink:

----------


## DJFireCFR

So just to update here.. I was messin around a bit, and installed some updated stuff... GeckoComplete (Which I think is Geckofx 2.0) and xulrunner 16.0b3  and when I try to run a debug, I get the following:


```
Unable to cast COM object of type 'System.__ComObject' to interface type 'Skybound.Gecko.nsInterfaces'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{A88E5A60-205A-4BB1-94E1-2628DAF51EAE}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
```

Which it highlights the following line under ApplicationEvents


```
Skybound.Gecko.Xpcom.Initialize(xrPath)
```

----------


## DJFireCFR

Hey Guys, I know this is a really old topic, but, Since its on this subject, Why create something new, when its based on the same thing?  (Zombie Apocalypse?)

Im trying to take this code here:


```
Private Sub AxWebBrowser1_NewWindow2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow2Event) Handles AxWebBrowser1.NewWindow2
    ' Dim t As New TabPage
    'Dim newtab As New tab
    '   newtab.Show()
    '  newtab.Dock = DockStyle.Fill
    ' newtab.AxWebBrowser1.RegisterAsBrowser = True
    'e.ppDisp = newtab.AxWebBrowser1.Application
    ' newtab.Visible = True
    ' newtab.TopLevel = False
    ' t.Controls.Add(newtab)
    ' Form1.TabControl1.TabPages.Add(t)
    ' Form1.TabControl1.SelectedTab = t
    '  newtab.Focus()
    'End Sub
```

And transform it to work with this:



```
    Private Sub GeckoWebBrowser1_CreateWindow(ByVal sender As Object, ByVal e As Skybound.Gecko.GeckoCreateWindowEventArgs) Handles GeckoWebBrowser1.CreateWindow
        Dim t As New TabPage
        Dim newtab As New tab
        newtab.Show()
        newtab.Dock = DockStyle.Fill
        newtab.GeckoWebBrowser1.RegisterAsBrowser = True
        e.ppDisp = newtab.GeckoWebBrowser1.Application
        newtab.Visible = True
        newtab.TopLevel = False
        t.Controls.Add(newtab)
        Form1.TabControl1.TabPages.Add(t)
        Form1.TabControl1.SelectedTab = t
        newtab.Focus()
    End Sub
```

The errors I am receiving are as follows:

1. 'RegisterAsBrowser' is not a member of 'Skybound.Gecko.GeckoWebBrowser'.

2. 'ppDisp' is not a member of 'Skybound.Gecko.GeckoCreateWindowEventArgs'.

3. 'Application' is not a member of 'Skybound.Gecko.GeckoWebBrowser'.


Would anyone know the "functions" of Skybound.Gecko, To get around those errors?  or how I can fix that so it works with Gecko.  Im trying to get out of using IE stuff for my browser, as its causing issues.. So I wanted to take another try using Gecko Engine.  But stuck at that point.

(again, I apologize for resurrecting an old thread)

----------


## Amerigo

Hello. I am creating a user control with a tabbed browser. I have followed the instructions in the original post exactly. I can add the geckobrowser to the control or to a test form without issue, but when trying to add my control to the test form, I get an error that xpcom can't be found. Then Visual Studio crashes. This happens with vs2010 or vs2013.

https://8fbb5527-a-62cb3a1a-s-sites....attredirects=0

----------


## sherif adely

Thanks alot Radjesh Klauke for your great thread .

I need your help as I made Webbrowser control using GeckoFX by VB.NET2010 but how to create a custom button control for saving the current html page as the following code is not working like the normal webbrowser in Visual studio tools

 Geckowebbrwoser.show save as dialogue

 So. please it would be highly appreciated if you kindly provide us with the codes needed for adding this feature to my project.

 Thanks in advance.

----------


## pdiclaudio

Dear Radjesh,
how we can active the download dialog box or only the file download on geckowebbrowser?
I tried your e example, run good, but not start the file download.
Thank's

----------

