在 VB.NET 项目中使用 GeckoWebBrowser (v45.0.34.0) [英] Using GeckoWebBrowser (v45.0.34.0) in a VB.NET project

查看:30
本文介绍了在 VB.NET 项目中使用 GeckoWebBrowser (v45.0.34.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让 GeckoWebBrowser(版本 45.0.34.0)控件在我的 VB.NET 项目中工作,但没有运气!!!

I am trying to make GeckoWebBrowser (version 45.0.34.0) control to work into my VB.NET project with no luck!!!

这是我遵循的步骤...

Here is the steps I follow...

1.我右键单击我的项目进入解决方案资源管理器列表,然后管理 NuGet 包.

1. I do right click on my project into Solution Explorer list and then Manage NuGet Packages.

2.我找到并安装 Geckofx45.

2. I find and install Geckofx45.

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

3. Then I go into my Project's properties, into Compile tab and I change Target CPU to x86.

4.重建我的项目.

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

5. Then I add GeckoWebBrowser control into my Toolbox by selecting the Geckofx-Winforms.dll file from ...\packages\Geckofx45.45.0.34\lib\net45 folder.

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

6. I add a GeckoWebBrowser control into my form and just for test, I do GeckoWebBrowser1.Navigate("www.google.com") into my form's Load event.

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

7. I Start my app and I get nothing!!!

有什么我遗漏的地方吗?

There is any step I miss or something?

推荐答案

在互联网上进行了令人筋疲力尽的 (!!!) 研究后,我设法让它工作了!!!以下是任何想要在他/她的 VB.NET 项目中使用 GeckoWebBrowser 的人的步骤.

After an exhausting(!!!) research over the internet, I managed to make it work!!! Here is the steps for anyone who want to use GeckoWebBrowser to his/her VB.NET project.

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

1. Create a new VB.NET project or just open an existing one.

2. 转到菜单项目,然后单击管理 NuGet 包.

2. Go to menu Project and click on Manage NuGet Packages.

3.点击浏览标签并搜索Geckofx45.

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

4. Choose the one with description: library that allows embeding gecko in C# applications and click Install button.

5. 关闭 NuGet 窗口并转到您项目的属性.

5. Close NuGet window and go to your project's Properties.

6.进入应用程序标签,点击查看应用程序事件按钮.

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

7. Delete everything in there and paste this part of code and save it.

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.现在,返回您的项目属性,点击编译选项卡并设置目标CPU> 值到 x86.

8. Now, go back to your project Properties, click on Compile tab and set the Target CPU value to x86.

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

9. Build or Rebuild your project.

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

10a. To add GeckoWebBrowser control into your Toolbox, first create a new Tab by then name GeckoFX 45 or whatever you like.

10b. 右键单击​​它,然后单击选择项目.

10b. Right click on it and click on Choose Items.

10b. 进入 .NET Framework 组件,然后点击浏览按钮.

10b. Go into .NET Framework Componetns and click Browse button.

10c.your-project-folder\packages\Geckofx45.45.0.34\lib\net45\Geckofx-Winforms.dll> 并点击打开按钮.

10c. Find Geckofx-Winforms.dll into your-project-folder\packages\Geckofx45.45.0.34\lib\net45\ and click Open button.

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

10d. Make sure that GeckoWebBrowser is checked and then click OK.

这篇关于在 VB.NET 项目中使用 GeckoWebBrowser (v45.0.34.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆