I'm trying to start two WebView2 browsers.
1 with arguments and 1 without arguments.
But i can't get it to work, i get a error with:
WebView_Browser2.CoreWebView2.Navigate("https://www.google.nl/")
Microsoft.Web.WebView2.WinForms.WebView2.CoreWebView2.get returned Nothing.
This is the code i have so far.
Private Async Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Await InitializeAsync()
End Sub
Private Async Function InitializeAsync() As Task
Dim opts As New CoreWebView2EnvironmentOptions With {.AdditionalBrowserArguments = "--kiosk-printing"}
Dim env = Await CoreWebView2Environment.CreateAsync(Nothing, Nothing, opts)
Await WebView_Browser1.EnsureCoreWebView2Async()
Await WebView_Browser2.EnsureCoreWebView2Async(env)
AddHandler WebView_Browser1.CoreWebView2.FrameNavigationCompleted, AddressOf WebView_Browser1_FrameNavigationCompleted
AddHandler WebView_Browser2.CoreWebView2.FrameNavigationCompleted, AddressOf WebView_Browser2_FrameNavigationCompleted
End Function
Private Sub WV_CoreWebView2Ready1(sender As Object, e As EventArgs) Handles WebView_Browser1.CoreWebView2InitializationCompleted
WebView_Browser1.CoreWebView2.Navigate("https://www.google.nl/")
End Sub
Private Sub WV_CoreWebView2Ready2(sender As Object, e As EventArgs) Handles WebView_Browser2.CoreWebView2InitializationCompleted
WebView_Browser2.CoreWebView2.Navigate("https://www.google.nl/")
End Sub
If i start both Await WebView_Browser1.EnsureCoreWebView2Async() with 'env' arguments they work.
But i would like to start 1 with and without arguments. Thank you for your time!
UPDATE
When i create two seperate CoreWebView2Environment.CreateAsync using no arguments i get the same error. If i change the Arguments to something else i get the error. But when i use the exact same arguments .AdditionalBrowserArguments = "--kiosk-printing"} it works. Maybe you can't start two WebView2 browsers on one form with different or one with and one without arguments?