EnsureCoreWebView2Async "invalid window handle" exception in Winform

0

when attempting to replace an AxWebBrowserwith WebView2 in an old winform form i get an "invalid window handle 0x80070578" exception.

at first it was due to an older version of Edge but after dating to Canary it was working fine in a standalone project.

async void InitializeAsync()
{
    await webView.EnsureCoreWebView2Async(null); //this throws an exception
}

what am i missing?

c#
winforms
webview2
asked on Stack Overflow Feb 22, 2021 by Danw25

1 Answer

0

Well, after a day of trying anything i could think of i noticed that the winform did not have a separate file for the designer. this got me thinking that maybe this is a compatibility thing (original form was created ~2015) so i attempted to recreate the winform in VS 2019.

recreating the form worked as expected. it runs smoothly now. also worth noting that the older form had this line

this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
answered on Stack Overflow Feb 22, 2021 by Danw25 • edited Feb 22, 2021 by Dharman

User contributions licensed under CC BY-SA 3.0