I have an application which utilizes GeckoFX/xulrunner 22. This program works great in Windows but no matter what I do I cannot get it to run in Linux nor Mac.
The primary focus is Mac though.
I've tried swapping out different versions of Windows, Linux & Mac xulrunner run-times as well as different initialization strings to try including both the Windows, Linux and Mac versions (of course only one at a time) like:
Gecko.Xpcom.Initialize("lib/xulrunner");
Gecko.Xpcom.Initialize("lib/XUL.framework/Versions/Current");
I have also tried prefixing with "./" as well as using code to obtain the current working directory to prepend to the path.
I've also tried copying over a dozen different versions of xul.dll into the executable folder and subdirectories within it.
No matter what I think to try, or search this site/google to try nothing has worked.
This is failing on the Initialize() call. The program/class names are only starred out so this is not the first thing popping up in google when people search for the program.
Although my biggest concern is getting this running on Mac, I will also mention due to other posts on Stack Overflow and alike that on my Linux system, I have tried having various versions of Firefox installed and the path pointed to as per other peoples' instructions. It always shows the same error as on Mac.
Error follows: Unhandled Exception: System.DllNotFoundException: xul at (wrapper managed-to-native) Gecko.Xpcom:Alloc (intptr) at Gecko.nsAString..ctor () [0x00000] in :0 at Gecko.nsAString..ctor (System.String value) [0x00000] in :0 at Gecko.Xpcom.Initialize (System.String binDirectory) [0x00000] in :0 at **********.**********.CreateBrowsers () [0x00000] in :0 at **********.**********.**********_Shown (System.Object sender, System.EventArgs e) [0x00000] in :0 at System.Windows.Forms.Form.OnShown (System.EventArgs e) [0x00000] in :0 at System.Windows.Forms.Form.SetVisibleCore (Boolean value) [0x00000] in :0 at System.Windows.Forms.Control.set_Visible (Boolean value) [0x00000] in :0 at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:set_Visible (bool) at System.Windows.Forms.Application.RunLoop (Boolean Modal, System.Windows.Forms.ApplicationContext context) [0x00000] in :0 at System.Windows.Forms.Application.Run (System.Windows.Forms.ApplicationContext context) [0x00000] in :0 at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm) [0x00000] in :0 at **********.Program.Main () [0x00000] in :0 [ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: xul at (wrapper managed-to-native) Gecko.Xpcom:Alloc (intptr) at Gecko.nsAString..ctor () [0x00000] in :0 at Gecko.nsAString..ctor (System.String value) [0x00000] in :0 at Gecko.Xpcom.Initialize (System.String binDirectory) [0x00000] in :0 at **********.**********.CreateBrowsers () [0x00000] in :0 at **********.**********.**********_Shown (System.Object sender, System.EventArgs e) [0x00000] in :0 at System.Windows.Forms.Form.OnShown (System.EventArgs e) [0x00000] in :0 at System.Windows.Forms.Form.SetVisibleCore (Boolean value) [0x00000] in :0 at System.Windows.Forms.Control.set_Visible (Boolean value) [0x00000] in :0 at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:set_Visible (bool) at System.Windows.Forms.Application.RunLoop (Boolean Modal, System.Windows.Forms.ApplicationContext context) [0x00000] in :0 at System.Windows.Forms.Application.Run (System.Windows.Forms.ApplicationContext context) [0x00000] in :0 at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm) [0x00000] in :0 at **********.Program.Main () [0x00000] in :0
Firstly, to my knowledge no one has ever run geckofx on OSX.
The problem you are seeing is probably easy fixable but before getting geckofx to work on mac you will likely hit more problems.
Geckofx's architecture on Windows is simple. The GeckoWebBrowser control is a winforms based control, which underneath are win32 controls and gecko/firefox on windows also uses win32 controls.
However on Linux things are a little more complicated as gecko/firefox uses GTK while the mono winform implementation is based upon X11. Hence geckofx has some fairly complex code to make that all work. (Which is why one needs to use a different build of geckofx on Linux (one with the GTK flag defined).
So firstly on OSX you have to determine what UI toolkit does mono uses for winforms, is it X11, carbon or something else? Then you have to determine which toolkit Firefox uses on OSX, carbon, cocoa or something else? If they happen to match then its probably worth proceeding with the windows build of geckofx. If they are different then you will probably have to modify geckofx itself to deal with this issue.
Now on to the DllNotFoundException.
The PInvoke/DllImport calls are probably looking for "xul.dll". This file could be named something different in OSX's firefox (eg. libxul.so) so a dllmap config file is needed to map xul.dll to the correct file.
Also setting these two environment variables, MONO_LOG_LEVEL="debug" and MONO_LOG_MASK="dll" should provide you with useful debug information.
Additionally one can use an absolute path for Gecko.Xpcom.Initialize to avoid any confusion about finding the path.