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 be Copy 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.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 = 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 Class
End 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"
Code:
-------------------------------------------------------------
10) Copy and paste the following code into your Form and run: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))
==================================