如何在 Mono/Windows 上使用 gecko-sharp 嵌入 Gecko?
Gecko 是 Firefox 的渲染引擎。 使用 gecko-sharp 可以将其嵌入到任何 Mono/GTK# 程序中。 有一个名为 GladeSharpBrowser 的示例应用程序可以执行此操作。 我可以设法使用修改后的项目文件来构建它,但它崩溃了。 这将帮助您重现问题:
我使用了 SharpDevelop 3.0 和 教程使用我的Mono 2.2 安装。 我已确保它使用 ProcMon 调用 Mono 的 gmcs 进行编译。 设置 SharpDevelop 后,必须修改 BrowserSharp.csproj 以便使用 Mono 进行编译。
还有一条警告消息:
发现不同之间存在冲突 相同依赖项的版本 组装。
这很奇怪,因为所有的程序集都是 Mono 提供的。
当然,还有其他方法,如 GeckoFX,但我特别感兴趣的是使用 Mono 以独立于平台的方式实现它。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于交叉兼容性问题来说,更好的答案可能是 Mono.WebBrowser,因为它最终可能是独立于引擎的。
http://www.mono-project.com/WebBrowser
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
解决问题的第一步是找出崩溃的原因。 根据您的指示构建 BrowserSharp 后(尽管我单独重新创建了 csproj),我运行:
使用 --debug 标志,mono 将打印出任何未处理的异常:
我在 Mono 发行版中找不到 gtkembedmoz.dll,但它出现是一个单独的安装。 可以在此处找到下载链接,以及一些旧但可能有用的说明此处。
我下载了稳定的 GRE 包并将 gtkembedmoz.dll 复制到构建目录中。 它仍然崩溃了,所以我使用 depends.exe 检查了依赖项,这清楚地表明它缺少 Gtk+库。 安装 gtk-sharp 运行时并将缺少的 dll 复制到构建中后我设法让它使用 Microsoft .NET 运行时运行。
由于某种原因,它仍然无法使用 Mono 工作。 我怀疑 Mono 搜索非托管 DLL 的方式存在一些差异,但我还没有研究过这一点。 无论您是否使用 Microsoft.NET 的 Mono,您可能都不需要将这些 DLL 复制到构建目录中,只需确保它们正确安装/配置以便可以找到它们即可。
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:
With the --debug flag, mono will print out any unhandled exception:
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.