[英]EnsureCoreWebView2Async “invalid window handle” exception in Winform
when attempting to replace an AxWebBrowserwith WebView2 in an old winform form i get an "invalid window handle 0x80070578" exception.当尝试在旧的 winform 表单中用 WebView2 替换 AxWebBrowser 时,我收到“无效的 window 句柄 0x80070578”异常。
at first it was due to an older version of Edge but after dating to Canary it was working fine in a standalone project.起初这是由于 Edge 的旧版本,但在与 Canary 约会后,它在独立项目中运行良好。
async void InitializeAsync()
{
await webView.EnsureCoreWebView2Async(null); //this throws an exception
}
what am i missing?我错过了什么?
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.好吧,在尝试了一天我能想到的任何事情之后,我注意到 winform 没有用于设计器的单独文件。 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.这让我想到这可能是一个兼容性问题(原始表单创建于 2015 年左右),所以我尝试在 VS 2019 中重新创建 winform。
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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.