Multi-threading issue with WebKitBrowser

0

I am trying to get two WebKitBrowser controls to navigate to a website at the same time.

I am running into a System.InvalidCastException error which is caused by the multi-threading as I read something related to marshalling but I am still stuck.

I attached the code below if that would help.

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

Error:

An unhandled exception of type 'System.InvalidCastException' occurred in WebKitBrowser.dll

Additional information: Unable to cast COM object of type 'WebKit.Interop.WebMutableURLRequestClass' to interface type 'WebKit.Interop.IWebMutableURLRequest'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C4042773-371F-427E-AFA9-9D4B358A0D93}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

.net
vb.net
multithreading
marshalling
asked on Stack Overflow Oct 10, 2016 by A.J • edited Jun 20, 2020 by Community

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0