'CoreWebView2 returned null
I am working on a custom web browser project, but when I try to navigate by using this code, the project generates an error.
(Controls["webView21"] as WebView2).CoreWebView2.Navigate("URL goes here");
It said that CoreWebView2 returned null even though I modified the source property without error. What can I do to fix this?
Solution 1:[1]
Try to call the EnsureCoreWebView2Async() method before accessing the CoreWebView2 property:
var webViewControl = Controls["webView21"] as WebView2;
await webViewControl.EnsureCoreWebView2Async();
webViewControl.CoreWebView2.Navigate("URL goes here");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mm8 |
