如何在 C# 中使用 Gecko
我需要一个 Gecko WebBrowser 控件
我需要一个示例代码或一个解释如何使用 GECKO 的链接
如果有人使用过 Gecko,我可以提供一些建议
I need a Gecko WebBrowser Control
I need a sample code or a link which explains how to use GECKO
If anyone has used Gecko, I could do with some advice
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
编辑: (2023-11-6)
可以找到最新更新此处。如果您觉得该文章有用,请点赞 :)
已过时:
2023 年 11 月 6 日:Gecko 的存储库为空。
带有详细快照的原始教程可以找到 这里。
要将 Gecko 浏览器嵌入到您的 winform 应用程序中,您需要:
XulRunner:XULRunner 是一个 Mozilla 运行时包,可用于引导与 Firefox 和 Thunderbird 一样丰富的 XUL+XPCOM 应用程序。它提供了安装、升级和卸载这些应用程序的机制。 XULRunner 可以在此处下载。选择您喜欢的版本。
GeckoFx .net 程序集文件,您可以从此处下载该文件。
还要选择与 XulRunner 版本匹配的正确版本。
解压GeckoFX-330.zip,您将得到以下文件:
将 GeckoWebBrowser 控件拖到 winform 设计器中,我们将其称为“浏览器”

在form1.cs文件中,添加以下代码:

Gecko.Xpcom.Initialize(@”..\xulrunner”) 行;指定 xulrunner 运行时所在的位置。在本例中,我们将其放入文件夹 (@”..\xulrunner”)。
现在运行应用程序,是啊~~~
Edit: (2023-11-6)
A most recent update can be found here. Please upvote in that article if you find it useful :)
Outdated:
2023-11-6: Gecko's repo is empty.
Original tutorial with detailed snapshots can be found here.
To embed Gecko browser in your winform application, you need:
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:
Drag a GeckoWebBrowser control to the winform designer, and let’s call it “browser”

In the form1.cs file, add below code:

The line Gecko.Xpcom.Initialize(@”..\xulrunner”); specifies where the xulrunner runtime is located. In this case, we put it into a folder (@”..\xulrunner”).
Now run the application, yeah~~~
您应该查看 http://code.google.com/p/geckofx/。要获取一些代码示例,请参阅Wiki 页面。
You should check out http://code.google.com/p/geckofx/. To get some code samples see the Wiki page.
将gecko浏览器添加到Winform中。
简短:
通过nuget安装Geckox60.64
将项目设置为 x64
将其添加到 Program.cs:
将 geckowebbrowser 控件拖到您的表单中。
将其添加到 form1_load:
就是这样。
长:
在 Visual Studio 中创建一个新的 Winform 应用程序。目前我的版本是 VS 2019。
转到Nuget。搜索Geckofx。找到最新版本,即v60。
安装Geckofx60.64
完成此操作后,您将在项目中看到一些更改:
Winform 控件已添加到您的 UI 工具箱
DLL 列表将添加到您的 bin/[debug |release]/Firefox 文件夹
运行应用程序,它应该崩溃或弹出异常!
重建并运行应用程序,万岁!成功了!
笔记:
他的回答已经过时了。从他的链接复制了这篇文章。
David Kou 的文章 , 示例GitHub 上的代码:
Add gecko browser into Winform.
Short:
Install Geckofx60.64 via nuget
set your project to x64
add this to Program.cs:
drag geckowebbrowser control to your form.
add this to form1_load:
That's it.
Long:
create a new Winform application in Visual Studio. Mine is VS 2019 as of now.
Go to Nuget. search Geckofx. find the latest version, which is v60.
Install Geckofx60.64
Once this is done, you will see some changes in your project:
A Winform control is added to your UI Toolbox
A list of DLLs are added to your bin/[debug |release]/Firefox folder
Run the app, it should crash or pop up with an exception!
Rebuild and run the app, hooray! It worked!
Note:
His answer was outdated. Copied the article here, From his link.
Article by David Kou , Example code at GitHub: