tags:

views:

1591

answers:

2

Gecko is the rendering engine for Firefox. Using gecko-sharp it is possible to embed it to any Mono/GTK# program. There is a sample application called GladeSharpBrowser for doing this. I could manage to build it using a modified project file, but it is crashing. This sould help you reproduce the problem:

I have used SharpDevelop 3.0 and a tutorial to set it up with my Mono 2.2 installation. I have made sure it calls Mono's gmcs for compilation using ProcMon. After setting up SharpDevelop, the BrowserSharp.csproj had to be modified so it compiles with Mono.

There is also a warning message:

Found conflicts between different versions of the same dependent assembly.

This is strange, since all the assemblies are the ones provided by Mono.

Sure, there are other methods like GeckoFX, but I am specifically interested in doing it in a platform independent manner using Mono.

+1  A: 

The first step to solving your problem is to figure out why it's crashing. After building BrowserSharp according to your instructions (although I recreated the csproj separately), I ran:

mono --debug BrowserSharp.exe
With the --debug flag, mono will print out any unhandled exception:
Unhandled Exception: System.TypeInitializationException: 
An exception was thrown by the type initializer for Gecko.WebControl --->
System.DllNotFoundException: gtkembedmoz.dll   
   at (wrapper managed-to-native) Gecko.WebControl:gtk_moz_embed_get_type ()
   ...

I couldn't find gtkembedmoz.dll in the Mono distribution, but it appears to be a separate install. A download link can be found here, and some old but possibly useful instructions here.

I downloaded the stable GRE package and copied the gtkembedmoz.dll into the build directory. It still crashed, so I checked the dependencies using depends.exe which made it clear that it was missing the Gtk+ libs. After installing the gtk-sharp runtime and copying the missing dlls into the build directory I managed to get it to run using the Microsoft .NET runtime.

For some reason it still didn't work using Mono. I suspect there is some difference in how Mono searches for unmanaged DLLs, but I haven't looked into this. Regardless of whether you use Mono of Microsoft.NET you probably shouldn't need to copy these DLLs into the build directory, it's just a matter of ensuring they're installed/configured properly so they'll be found.

Dave
+1  A: 

Whats probably a better answer to your cross-compatibility issue is the Mono.WebBrowser, as it could be engine independent eventually.

http://www.mono-project.com/WebBrowser

kkubasik