在 VB.NET 项目中使用 GeckoWebBrowser (v45.0.34.0)

Using GeckoWebBrowser (v45.0.34.0) in a VB.NET project

我正在尝试使 GeckoWebBrowser(版本 45.0.34.0)控件在我的 VB.NET 项目中工作,但不幸的是!!!

这是我遵循的步骤...

1. 我右击我的 项目 进入 Solution Explorer 列表然后管理 NuGet 包

2. 我找到并安装 Geckofx45.

3. 然后我进入我的 项目的属性 ,进入 编译选项卡 然后我将 目标 CPU 更改为 x86.

4.重建 我的项目。

5. 然后我通过选择 Geckofx-[ 将 GeckoWebBrowser 控件添加到我的 工具箱 =80=] 文件来自 ...\packages\Geckofx45.45.0.34\lib\net45 文件夹。

6. 我在 表单 中添加了一个 GeckoWebBrowser 控件,只是为了测试,我做了 GeckoWebBrowser1.Navigate("www.google.com") 进入我的表单的 Load 事件。

7.启动我的应用程序,但我什么也没得到!!!

我漏掉了什么步骤吗?

经过 Internet 上令人筋疲力尽的 (!!!) 研究后,我终于成功了!!!以下是任何想要使用 GeckoWebBrowser 来 his/her VB.NET 项目的人的步骤。

1. 创建一个新的 VB.NET 项目或只打开一个现有项目。

2. 转到菜单 Project 并单击 Manage NuGet Packages.

3. 单击 浏览 选项卡并搜索 Geckofx45.

4. 选择描述为允许在 C# 应用程序中嵌入 gecko 的库,然后单击 安装按钮。

5. 关闭 NuGet window 并转到项目的 Properties .

6. 进入 Application 选项卡,单击 View Application Events 按钮。

7.删除里面的所有内容,粘贴这部分代码保存。

Imports Gecko
Imports System.IO
Namespace My
    ' The following events are available for MyApplication:
    '
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication
        Protected Overrides Function OnStartup(ByVal eventArgs As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) As Boolean
            Dim ProfileDirectory As String = My.Application.Info.DirectoryPath & "\Firefox\Profile"
            If Not Directory.Exists(ProfileDirectory) Then
                Directory.CreateDirectory(ProfileDirectory)
            End If
            Xpcom.ProfileDirectory = ProfileDirectory
            Gecko.Xpcom.Initialize("Firefox")
            Return True
        End Function
    End Class
End Namespace

8. 现在,返回您的项目 Properties,单击 Compile 选项卡并将 Target CPU 值设置为 x86.

9. 构建或重建您的项目。

10a. 要将 GeckoWebBrowser 控件添加到您的 工具箱 ,首先创建一个新的 Tab 然后命名为 GeckoFX 45 或任何你喜欢的名称。

10b. 右键单击​​它并单击 选择项目.

10b. 进入 .NET Framework Componetns 并单击 Browse 按钮。

10c.your-project-folder\packages\Geckofx45.45.0.34\lib\net45\中找到Geckofx-Winforms.dll然后点击打开按钮。

10d. 确保选中 GeckoWebBrowser 然后单击 确定.