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

青春壹個敷衍的年華 提交于 2019-12-05 07:27:33

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

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.

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