How do I embed Gecko using gecko-sharp on Mono/Windows?

南笙酒味 提交于 2019-12-07 03:01:44

问题


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:


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




回答2:


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.



来源:https://stackoverflow.com/questions/478611/how-do-i-embed-gecko-using-gecko-sharp-on-mono-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!