如何在 C# 中使用 Gecko
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8778320/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use Gecko in C#
提问by DanMatlin
I need a Gecko WebBrowser Control
我需要一个 Gecko WebBrowser 控件
I need a sample code or a link which explains how to use GECKO
我需要一个示例代码或一个解释如何使用 GECKO 的链接
If anyone has used Gecko, I could do with some advice
如果有人用过 Gecko,我可以提供一些建议
回答by Johnny Graber
You should check out http://code.google.com/p/geckofx/. To get some code samples see the Wiki page.
您应该查看http://code.google.com/p/geckofx/。要获取一些代码示例,请参阅Wiki 页面。
回答by David
Original tutorial with detailed snapshots can be found here.
可以在此处找到带有详细快照的原始教程。
A most recent update can be found here. Please upvote in that article if you find it useful :)
可以在此处找到最新更新。如果您觉得有用,请在该文章中点赞 :)
To embed Gecko browser in your winform application, you need:
要将 Gecko 浏览器嵌入到您的 winform 应用程序中,您需要:
- XulRunner: XULRunner is a Mozilla runtime package that can be used to bootstrap XUL+XPCOM applications that are as rich as Firefox and Thunderbird. It provides mechanisms for installing, upgrading, and uninstalling these applications. XULRunner can be downloaded here. Choose the version you like.
GeckoFx .net assembly file, which you can download from here. Also choose the correct version which matches the XulRunner version.
Unpack the GeckoFX-330.zip, you will get below files:
- XulRunner:XULRunner 是一个 Mozilla 运行时包,可用于引导与 Firefox 和 Thunderbird 一样丰富的 XUL+XPCOM 应用程序。它提供了安装、升级和卸载这些应用程序的机制。XULRunner 可以在这里下载。选择你喜欢的版本。
GeckoFx .net 程序集文件,您可以从这里下载。还要选择与 XulRunner 版本匹配的正确版本。
解压 GeckoFX-330.zip,你会得到以下文件:
- Add references to the dlls as shown above, click browse and select the Geckofx-Core.dll and Geckofx-Winforms.dll
- 添加对 dll 的引用,如上所示,单击浏览并选择 Geckofx-Core.dll 和 Geckofx-Winforms.dll
- In the toolbox, right click, and then select “Choose Item”, select Geckofx-Winforms.dll, and the Gecko winform control will be shown in the toolbox
- 在工具箱中右击,然后选择“Choose Item”,选择Geckofx-Winforms.dll,工具箱中就会出现Gecko winform控件
The line Gecko.Xpcom.Initialize(@”..\xulrunner”); specifies where the xulrunner runtime is located. In this case, we put it into a folder (@”..\xulrunner”).
行 Gecko.Xpcom.Initialize(@"..\xulrunner"); 指定 xulrunner 运行时所在的位置。在本例中,我们将其放入一个文件夹(@”..\xulrunner”)。
Now run the application, yeah~~~
现在运行应用程序,是的~~~


