How to enable Gecko using gecko-sharp in Mono / Windows?

Gecko is a rendering engine for Firefox. With gecko-sharp, you can embed it in any Mono / GTK # program. To do this, there is an example application GladeSharpBrowser . I managed to create it using a modified project file, but it fails. This will help you reproduce the problem:

I used SharpDevelop 3.0 and a tutorial to configure it using Mono 2.2 . I made sure it calls Mono gmcs to compile with ProcMon. After setting up SharpDevelop, BrowserSharp.csproj had to be changed, 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 assemblies are files provided by Mono.

Of course, there are other methods, such as GeckoFX, but I'm specifically interested in doing this in a platform-independent way using Mono.

+6
c # gecko mono
source share
2 answers

Probably the best answer to the cross-compatibility issue is Mono.WebBrowser, as it may ultimately be engine independent.

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

+2
source share

The first step to solving your problem is finding out the reasons for the failure. After creating BrowserSharp according to your instructions (although I recreated csproj separately), I ran:

  mono --debug BrowserSharp.exe 

With the flag --debug mono will throw 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 could not find gtkembedmoz.dll in the Mono distribution, but it seems to be a separate installation. Link to link can be found here and some old, but possibly useful instructions.

I downloaded the stable GRE package and copied the gtkembedmoz.dll file to the build directory. It still crashed, so I checked the dependencies using depend.exe , in which it was clear that it lacked Gtk + libs. After installing gtk-sharp runtime and copying the missing DLLs to the assembly directory, I was able to run it using the Microsoft.NET runtime.

For some reason, it still didn't work with Mono. I suspect there is some difference in how Mono searches for unmanaged DLLs, but I have not considered this. Regardless of whether you use Mono from Microsoft.NET, you probably will not need to copy these DLLs to the assembly directory, it is just a matter of ensuring they are installed and configured correctly so that they are found.

+1
source share

All Articles