我正在将浏览器集成到我的软件中。当我继续打开新的浏览器选项卡时它正在工作,但是一旦我关闭一个选项卡并尝试打开新的选项卡,它就会在以下代码中产生异常。
public async Task InitCore()
{
try
{
// Initialization.
await webView.EnsureCoreWebView2Async(null);
// This line gives exception if I close a tab and reopen as it gives exception in Initialization.
}
catch (Exception ex)
{
Enumerations.WriteToLog(Enumerations.LogType.Misc, "Browser.InitCore " + ex.ToString());
}
}
// Subscribing events.
private void AfterCoreReady(object sender,EventArgs e)
{
label1.Visible = false;
this.webView.CoreWebView2.ContentLoading += webView_ContentLoading;
this.webView.CoreWebView2.NewWindowRequested += webView_NewWindowRequested;
}
Run Code Online (Sandbox Code Playgroud)
关闭选项卡后重新初始化时出现以下异常:
CustomWebView2.OnEnter System.Runtime.InteropServices.COMException (0x8007139F):
The group or resource is not in the correct state to perform the requested operation. …Run Code Online (Sandbox Code Playgroud)