0

How do I debug this? Thanks in advance! Code is several hundred lines of VB.NET and part of a larger set of code; this is the logic flow. Replacing an Internet Explorer WebBrowser control based application. The time for WebView2_CoreWebView2InitializationCompleted indicates if it will work or fail.

Windows .NET framework form creates form containing WebView2 V1.0.1264.42 When run in Visual Studio 2019 works. When run from command prompt, fails.

  1. WebView2 form: form load event call async InitializeCoreWebView2Async

  2. InitializeCoreWebView2Async: 2a) CoreWebView2Environment cwv2Environment = Await CoreWebView2Environment.CreateAsync(Nothing, userDataFolder, options) 2b) Await WebView2.EnsureCoreWebView2Async(cwv2Environment)

  3. WebView2_CoreWebView2InitializationCompleted is raised (either 3550 milliseconds and rest works or ~600 milliseconds and rest fails) 3a) UserDataFolder is confirmed as set 3b) adds event handlers for: WebView2.CoreWebView2.WebResourceRequested WebView2.CoreWebView2.WebResourceResponseReceived WebView2.CoreWebView2.DownloadStarting 3c) WebView2.CoreWebView2.AddWebResourceRequestedFilter("*",Microsoft.Web.WebView2.Core.CoreWebView2WebResourceContext.All) 3d) CoreWebView2WebResourceRequest request = WebView2.CoreWebView2.Environment.CreateWebResourceRequest( URIToNavigateTo, "POST", streamBodyToUpload, "Content-Type: application/vnd.microsoft.portable-executable") 3e) WebView2.CoreWebView2.NavigateWithWebResourceRequest(request)

  4. WebView2_NavigationStarting is raised 4a) CoreWebView2WebResourceRequestedEventArgs.ResourceContext is "Document"

5)When this works only in Visual Studio: 5a) CoreWebView2_WebResourceResponseReceived There is a header with Transfer-Encoding chunked

5b) WebView2_NavigationCompleted 5c) Webview2_DownloadStarting 6 - 10) Remaining download events fire and download is completely received

  1. When this fails, nothing occurs until a timeout of unable to reach the server 5a) CoreWebView2_WebResourceResponseReceived Header "image/svg+xml"
  • 1
    Your post is difficult to understand. Please format any code as code. The following may be helpful: [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example). For WebView2, the following may be helpful: https://stackoverflow.com/a/70645764/10024425 and https://stackoverflow.com/a/71699939/10024425 – Tu deschizi eu inchid Jul 16 '22 at 03:26
  • If I could insert a flowchart I would; what I have asked is specifically how to debug CoreWebView2Initialization. The program is about 2,000 lines of async event handlers and the verbiage discusses the flow which works except with a specific incorrect initialization which fires WebView2_CoreWebView2InitializationCompleted before the initialization has really completed. – Ira Grollman Jul 18 '22 at 00:36
  • Don't place any navigation (ie: `NavigateWithWebResourceRequest`) inside of `CoreWebView2InitializationCompleted` - you can subscribe to events within `CoreWebView2InitializationCompleted`, but that's not really necessary either. Place `NavigateWithWebResourceRequest` after `await InitializeCoreWebView2Async...`. Also, ensure that the `Source` property hasn't been set. – Tu deschizi eu inchid Jul 18 '22 at 01:10

0 Answers0