GeckoFx And XULRunner to use firefox as webbrowser

pdabasic

Active Member
Licensed User
I have a firefox optimised webaplication, so I need a firefox wrapper.
The link is very old but the xulrunner latest version use the same as firefox 16.02
 

Basic4Life

Member
Licensed User
Here's a quick and dirty wrapper for geckoFX.
To get it to run you have to download the xulrunner from here
http://ftp.mozilla.org/pub/mozilla.....2/runtimes/xulrunner-1.9.1.2.en-US.win32.zip
and put the xulrunner folder in the same folder as the example or you can change the xulrunner path in GeckoWebBrowser.New()

This should give you very basic functionality, but geckoFX is not compatible with 16.02, so you are probably stuck with 1.9.1, you could try later versions and see if they work.

There's also a bug that requires to restart b4p after you run the program from b4p.
 

pdabasic

Active Member
Licensed User
Thank you Basic4Life, again you are the best!

Can you give me the source code?
I think after the example i can set it up to date.

Why should be the restart bug?
 

Basic4Life

Member
Licensed User
You're welcome.
The source code is already in the zip file, b4pgeckoFX15.cs (you can insert that into an empty dll project, just make sure you add the reference to the 2 geckoFX libraries)

I think the bug is caused by the Runtime Callable Wrapper not being properly released, when the program is started from b4p and then closed, so if you start it again without restarting b4p, there's an error.
It shouldn't be a problem in the compiled program though.
 
Last edited:

pdabasic

Active Member
Licensed User
In that program, with what you made the program (sharp develop) did the same problem occur? Can this fault cause any long term problem in the Windows system while trying it?
 

Basic4Life

Member
Licensed User
No, when you use the wrapper in the Sharp Develop IDE the error does not occur, that's because if you run the program from sd, it will run in its own process, when you close the program window, that process ends (and everything gets cleaned up).
If you run the program from b4p it runs in the same process as b4p, so when you close the window, the b4p process still runs. That's were the issue probably comes from(I read somewhere, that XPCOM components can't stop and restart in the same process, so that might explain the error on the second start)
I don't have any experience with this, there might be a way to handle all this alot better in the wrapper, but I don't know it.
This shouldn't cause any long term problems for windows, it should all get cleaned up when the b4p process is closed.
 
Last edited:

agraham

Expert
Licensed User
Longtime User
there might be a way to handle all this a lot better in the wrapper, but I don't know it.
If you are correct about the RCW then calling Marshal.ReleaseComObject on the instance will (should!) force the release of it immediately. If you make your wrapper class inherit IDisposable then Basic4ppc will always call Dispose() on instances of it when the main form of the program closes in both the IDE and when compiled. It does this for all library objects
 

pdabasic

Active Member
Licensed User
agraham what does it mean on "basic" language?
I only need a simply wrapper just run the web page an I need to close it.

This need me to a kiosk aplication with a barcode reader, but the webap works best on firefox.
The firefox kiosk addons not so perfecct and I need to set the reader in the background and shutdown the computer under a simple b4p menu.
 
Last edited:

pdabasic

Active Member
Licensed User
Appropo: The project works perfect with the actual firefox version number with 16.0.2 xulrunner too
 

agraham

Expert
Licensed User
Longtime User
Ah, I understand now. Actually Marshal.FinalReleaseComObject looks better. I have no idea if this will work.

public class GeckoWebBrowser : IDisposable
{

...

public void Dispose()
{
browser.DocumentCompleted -= new EventHandler(DocumentCompleted);
Marshal.FinalReleaseComObject(browser);
browser.Dispose();
}
 

agraham

Expert
Licensed User
Longtime User
Actually it has just occurred to me that Marshal.FinalReleaseComObject might not be necessary as long as GeckoWebBrowser inherits IDisposable, which it doesn't at the moment so it's Dispose method is not at the moment being called by Basic4ppc to dispose the browser instance. Try both with and without the Marshal statement.
 
Last edited:

Basic4Life

Member
Licensed User
Thanks a lot for your input.
I tried all of them and all combinations of them , but the error on the second start is still there:
"COM object that has been separated from its underlying RCW cannot be used"
When one uses "browser" as object in the Marshal.Release method it errors, saying it's not a type of __COM object.
I tried the build in XPCOM methods .Free() and .Shutdown(). I also tried the GetObjectForUnknown method, but it doesn't seem to support ":IUnknown"
From what I could gather, it seems there's no way to destroy the COM object, so in the IDE it will always try to connect to the same COM object.
One idea might be assigning GUIDs to all objects and distinguish them by that, but I don't really know much about that.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…