简体   繁体   English

EnsureCoreWebView2Async Winform 中出现“无效的 window 句柄”异常

[英]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.

相关问题 在WebView2 中初始化EnsureCoreWebView2Async(null) 时出现异常 - Exception while initializing EnsureCoreWebView2Async(null) in WebView2 WPF 中的 WebView2:EnsureCoreWebView2Async 在没有任何异常或错误的情况下永远不会完成 - WebView2 in WPF: EnsureCoreWebView2Async never finishes without any exception or error 即使在 CoreWebView2InitializationCompleted 事件之后,EnsureCoreWebView2Async 也没有准备好 - EnsureCoreWebView2Async not ready even after CoreWebView2InitializationCompleted event 在 WPF 中打开 WebView2 会在调用 EnsureCoreWebView2Async 时导致 System.UnauthorizedAccessException - Opening WebView2 in WPF causes System.UnauthorizedAccessException while calling EnsureCoreWebView2Async 关闭承载 Windows 窗体控件的 WPF 用户控件的 WinForm 时无效的窗口句柄 - Invalid Window Handle when closing a WinForm that hosts a WPF UserControl that hosts a Windows Forms control Unity UWP FolderPicker引发无效的窗口句柄异常 - Unity UWP FolderPicker Throws Invalid Window Handle Exception 处理无效的窗口句柄 - Handling invalid window handle 无效的窗口句柄 - Invalid window handle MoveWindow返回“无效的窗口句柄” - MoveWindow returns “Invalid Window Handle” 使用 lambda 异步处理异常,未捕获异常 - Handle exception with lambda async, exception not caught
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM