我想让两个WebKitBrowser控件同时导航到一个网站。
我遇到了System.InvalidCastException
错误,这是由多线程引起的,当我读到与编组有关的内容但我仍然卡住了。
如果有帮助,我附上了以下代码。
Imports System.Runtime.InteropServices
Public Class Form1
Dim thread As System.Threading.Thread
Dim thread2 As System.Threading.Thread
Private Sub countup()
WebKitBrowser1.Navigate("http://www.google.com")
End Sub
Private Sub countup2()
WebKitBrowser2.Navigate("http://www.google.com")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
thread = New System.Threading.Thread(AddressOf countup)
thread.Start()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs)
thread2 = New System.Threading.Thread(AddressOf countup2)
thread2.Start()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CheckForIllegalCrossThreadCalls = False
End Sub
End Class
错误:
WebKitBrowser.dll中出现未处理的“System.InvalidCastException”类型异常
其他信息:无法将“WebKit.Interop.WebMutableURLRequestClass”类型的COM对象强制转换为接口类型“WebKit.Interop.IWebMutableURLRequest”。此操作失败,因为由于以下错误,对IID为“{C4042773-371F-427E-AFA9-9D4B358A0D93}”的接口的COM组件的QueryInterface调用失败:加载类型库/ DLL时出错。 (来自HRESULT的异常:0x80029C4A(TYPE_E_CANTLOADLIBRARY))。