-
Notifications
You must be signed in to change notification settings - Fork 58
Description
Description
We have some customers that are encountering this exception when our code is creating a WebView2 control hosted in a Winform. The UserDataFolder used is specific to the user and not shared by other apps. We use the same CoreWebView2Environment properties when calling EnsureCoreWebView2() for subsequent WV2 controls we create. We are unable to reproduce the issue in-house.
COMException: The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F)
Source: mscorlib
Stack:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at Microsoft.Web.WebView2.Core.CoreWebView2Environment.<CreateCoreWebView2ControllerAsync>d__41.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Web.WebView2.WinForms.WebView2.<InitCoreWebView2Async>d__13.MoveNext()
Version
SDK: 1.0.1343.22
Runtime: 107.0.1418.52
Framework: WinForms
OS: Win10, exact version info not yet if available
VSTO Add-in running in Excel
Repro Steps
Our code does in essence, the following.
In our Winform that hosts the WV2 control:
private void HandleFormLoaded (object sender, EventArgs e)
{
await WebView2Control.InitializeWebView2Async (); // WebView2Control is an instance of our subclass of WebView2
// once init is complete, we navigate to a URL in the WV2
}
In our subclass of Microsoft.Web.WebView2.WinForms.WebView2
:
public async Task InitializeWebView2Async ()
{
CoreWebView2EnvironmentOptions options = new CoreWebView2EnvironmentOptions ()
{
AdditionalBrowserArguments = // <snip> nothing interesting
Language = // something appropriate,
AllowSingleSignOnUsingOSPrimaryAccount = true,
};
string userDataFolder = // something that resolves to %LocalAppData%\MyCompany\Our Addin Name\
CoreWebView2Environment webView2Environment = await CoreWebView2Environment.CreateAsync (null, userDataFolder, options);
await EnsureCoreWebView2Async (webView2Environment); // this is the base class impl: WebView2.EnsureCoreWebView2Async
}
In our event handler for CoreWebView2InitializationCompleted
, we get e.IsSuccess
= false with e.InitializationException
as shown in the stack above.
Additional context
We saw this GH issue: #2495, which might be related, but the exception stacks there are WPF so they don't match ours exactly..
We have multiple customers at different companies encountering this issue. We also have many customers across companies not encountering this issue.
Diagnostics
We are unable to use a debugger at the customer sites.
How can we capture additional logs from the customer to help us diagnose the root cause of the exception?