What happened?
While running some local tests using involving opening and closing multiple WebView2 components one after another, one of our users suddenly started getting the error "The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F)", with the following stack trace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.Web.WebView2.Core.CoreWebView2Environment.d__15.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Web.WebView2.WinForms.WebView2.d__25.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Now, anytime they run any of our applications and attempt to open a WebView2 control, they get the same error - including both deployed and local versions of the applications. Looking through some of the issues on this page, we tried a few things to fix this, but none of them worked. This includes:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
-
Repairing and reinstalling the WebView2 runtime
-
Deleting the application User Data folder, and even setting a custom User Data folder in one of our applications' WebView2 environment to see if we could start from a blank slate
Ultimately, none of this worked. Are there any other workarounds that might fix the immediate issue?
Also, aside from ensuring that each application has a single shared WebView2 environment (which we did not do prior to this and may have caused this issue in the first place), are there any other best practices to avoid having this issue happen again? It would be very problematic if it happened to one of our clients.
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
No response
SDK Version
No response
Framework
Winforms
Operating System
Windows 11
OS Version
No response
Repro steps
Attempt to create and close multiple WebView2 components, each with their own CoreWebView2Environment that is generated using default values. It is expected to successfully create each one, but there appears to be a chance after the second one for any new WebView2 components to throw an exception when attempting to call EnsureCoreWebView2Async.
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Don't know
Last working version (if regression)
No response
What happened?
While running some local tests using involving opening and closing multiple WebView2 components one after another, one of our users suddenly started getting the error "The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F)", with the following stack trace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.Web.WebView2.Core.CoreWebView2Environment.d__15.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Web.WebView2.WinForms.WebView2.d__25.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Now, anytime they run any of our applications and attempt to open a WebView2 control, they get the same error - including both deployed and local versions of the applications. Looking through some of the issues on this page, we tried a few things to fix this, but none of them worked. This includes:
Restarting the computer to shut off any interfering processes
Checking for any Edge-related Parameters under the following registry keys (none were present)
Repairing and reinstalling the WebView2 runtime
Deleting the application User Data folder, and even setting a custom User Data folder in one of our applications' WebView2 environment to see if we could start from a blank slate
Ultimately, none of this worked. Are there any other workarounds that might fix the immediate issue?
Also, aside from ensuring that each application has a single shared WebView2 environment (which we did not do prior to this and may have caused this issue in the first place), are there any other best practices to avoid having this issue happen again? It would be very problematic if it happened to one of our clients.
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
No response
SDK Version
No response
Framework
Winforms
Operating System
Windows 11
OS Version
No response
Repro steps
Attempt to create and close multiple WebView2 components, each with their own CoreWebView2Environment that is generated using default values. It is expected to successfully create each one, but there appears to be a chance after the second one for any new WebView2 components to throw an exception when attempting to call EnsureCoreWebView2Async.
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Don't know
Last working version (if regression)
No response