Mozilla / Firefox / Gecko in VB.NET,geckofx 1.9 vb.net中使用方法
来源:互联网 发布:linux无法解压zip 编辑:程序博客网 时间:2024/06/05 21:12
1、下载Skybound.Gecko.dll
2、运行错误会自动下载xulrunner-1.9.1.2.en-US.win32
特别是老提示
“System.BadImageFormatException”类型的第一次机会异常在 Skybound.Gecko.dll 中发生
“System.NullReferenceException”类型的第一次机会异常在 Skybound.Gecko.dll 中发生
此时将xulrunner-1.9.1.2.en-US.win32包中的文件覆盖就能解决
3、Application.Designer.vb添加
Protected Overrides Function OnStartup(ByVal eventArgs As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) As Boolean Dim ProfileDirectory As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\xulrunner\DefaultProfile" If Not Directory.Exists(ProfileDirectory) Then Directory.CreateDirectory(ProfileDirectory) End If Xpcom.ProfileDirectory = ProfileDirectory Dim xrPath As String = System.Reflection.Assembly.GetExecutingAssembly.Location 'xrPath = xrPath.Substring(0, xrPath.LastIndexOf("\") + 1) & "\subfolder\xulrunner" xrPath = xrPath.Substring(0, xrPath.LastIndexOf("\") + 1) & "\xulrunner" Xpcom.Initialize(xrPath) Return True End Function
4、解压xulrunner-1.9.1.2.en-US.win32到bin\debug 目录下 形成类似 F:\_05LinyeeSourceCode\vb.net\Org.Linyee.Program.LyWeb\VBNETLyweb\bin\Debug\xulrunner 这个的目录
5、继承时 Inherits Skybound.Gecko.GeckoWebBrowser
<System.Diagnostics.DebuggerNonUserCode()> _ Public Sub New() MyBase.New() '组件设计器需要此调用。 InitializeComponent() Dim ProfileDirectory As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\xulrunner\DefaultProfile" If Not Directory.Exists(ProfileDirectory) Then Directory.CreateDirectory(ProfileDirectory) End If Xpcom.ProfileDirectory = ProfileDirectory Dim xrPath As String = System.Reflection.Assembly.GetExecutingAssembly.Location 'xrPath = xrPath.Substring(0, xrPath.LastIndexOf("\") + 1) & "\subfolder\xulrunner" xrPath = xrPath.Substring(0, xrPath.LastIndexOf("\") + 1) & "\xulrunner" Xpcom.Initialize(xrPath) End Sub
附注:经实现 在New 或form_load中添加 Xpcom.Initialize(xrPath)均不起作用,会报错。
以上为Linyee(jiaguoxinzhi)所添加
================================================
Mozilla / Firefox / Gecko in VB.NET
Here's a very easy to follow tutorial how to implement the Firefox/Gecko plugin within Visual Studio and use it as an IE replacement.It's faster and safer and better then the IE component and no IE or other browser needed on the client-computer to make it work.
These are only the very basics to make it work.
========================================================
1) Download and extract: http://releases.mozilla.org/pub/mozi...n-US.win32.zip
Within the extracted folder You find a folder with the name "xulrunner"
2) Drag the whole folder (including sub-folders and files) to your solution explorer;
3) Now, every file! within the xulrunner-folder need to beCopy To Output Dir ->Copy if Newer
4) Download and extract: http://geckofx.googlecode.com/files/...n.v1.9.1.0.zip
5) Cut/copy the file "Skybound.Gecko.dll" from the bin-folder and place it where ever you want. There is no need for the rest so you can throw that away.
6) Now you need to add the "Skybound.Gecko.dll" to your toolbox.
- right-click the "Toolbox" and select "Choose Items...";
- click "browse" in the ".NET Frameworks components" Tab;
- search for the Skybound.Gecko.dll and press OK; (GeckoWebbrowser appears, see image below. I created a new tab for the component. You can do that also.)
Now we can do stuff:
7) Add the component and a button to your Form;
UPDATED 25-03-2011
-------------------------------------------------------------
8) Open the properties of your application;
9) Click on "View Application Events" in the "Application"-tab;
Copy and past the following:Code:Imports Skybound.GeckoImports System.IONamespace 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 = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\subfolder\xulrunner\DefaultProfile" If Not Directory.Exists(ProfileDirectory) Then Directory.CreateDirectory(ProfileDirectory) End If Xpcom.ProfileDirectory = ProfileDirectory Dim xrPath As String = System.Reflection.Assembly.GetExecutingAssembly.Location xrPath = xrPath.Substring(0, xrPath.LastIndexOf("\") + 1) & "\subfolder\xulrunner" Xpcom.Initialize(xrPath) Return True End Function End ClassEnd Namespace
You can change the name and path of the folder like you want it to be. This means you can also change the name "xulrunner"
-------------------------------------------------------------
10) Copy and paste the following code into your Form and run:==================================Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click GeckoWebBrowser1.Navigate("http://www.radjesh.nl")End Sub
http://www.mediafire.com/?9s95u1ex9zj4q19 <<< Download example (7MB (.rar))
==================================
- Mozilla / Firefox / Gecko in VB.NET,geckofx 1.9 vb.net中使用方法
- vb.net datagridview 使用方法
- vb.net datagridview 使用方法
- vb.net中类的使用方法
- vb.net 中LOG4net的使用方法!
- vb.net中自定义事件的使用方法
- VB.Net中HOOK的使用方法
- VB.NET中treeview使用方法一
- TraceLog in VB.NET
- Callback in vb.net
- .NET gecko内核浏览器开发 ——GeckoFX介绍
- 'VB.net 自定义事件使用方法
- 'VB.net 自定义事件使用方法
- [VB.NET]vb.net中 listbox 问题
- vb.net 学习中..
- VB.NET中Module
- VB.NET中四舍五入
- Service Management in VB.NET
- 蛋疼的ViewPager+竖直SeekBar实现过程(1)竖直SeekBar实现
- 斥巨资打造鹰目LED联播网
- stm32 利用Flash进行储存数据
- 给IT新人的15点建议:苦逼程序员的辛酸反省与总结
- 从4.0.4 master分支移植到4.0.4_r1
- Mozilla / Firefox / Gecko in VB.NET,geckofx 1.9 vb.net中使用方法
- 鸟哥教会我的一些命令
- 如何将decimal保留小数位后两位,使用四舍五入,利用时间差计算部分时间
- Activating Change Pointers
- Android Canvas drawArc方法介绍
- android中自定义属性的使用
- 设计模式:备忘录模式
- 删除 Change Pointers
- 信息安全继海、陆、空、天成为“第五维”战场!!