-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Problem/Bug]: Exception on Dispose() of WPF WebView2 control #4263
Comments
I am also facing same issue which is leading to a crash. Can you please look into this ASAP. |
Hey @imranp23 / @adakaraju - Do either of you have a sample app that reproduces this issue that we could take a look at? In the past, the issue with the Finalizer doing the WebView2 cleanup is that it could happen on a background thread, rather than the thread the WebView2 was created on. |
@champnic I will look into getting a minimal example, but in the meantime, I get a similar issue:
I am just accessing I can access it earlier - like when I'm navigating the webview2. |
WebView2 should only be accessed by a single thread - is that task running on the same thread that created the WebView2? |
@champnic oh probably not. Thanks |
What happened?
I am using Microsoft.Web.WebView2.Wpf.WebView2 object as a static member of a singleton class which is used across application.
In Xaml window, I am adding this object to UI Grid as children at runtime whenever I need it and removing it from the same Grid on closing of the window.
While closing the application this singleton class is disposing the WebView2 object which is invoked on UI thread.
Still facing the Exception as below,
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Web.WebView2.Core.Raw.ICoreWebView2Controller'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{4D00C0D1-9434-4EB6-8078-8697A560334F}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
at Microsoft.Web.WebView2.Core.Raw.ICoreWebView2Controller.get_CoreWebView2()
at Microsoft.Web.WebView2.Core.CoreWebView2Controller.get_CoreWebView2()
at Microsoft.Web.WebView2.Wpf.WebView2.Uninitialize(Boolean browserCrashed)
at Microsoft.Web.WebView2.Wpf.WebView2.Dispose(Boolean disposing)
at System.Windows.Interop.HwndHost.Finalize()
Importance
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
120.0.2210.91
SDK Version
1.0.1518.46
Framework
WPF
Operating System
Windows 10, Windows 11
OS Version
No response
Repro steps
Calling WebView2.Dispose() at end of application.
Repros in Edge Browser
Not Applicable
Regression
Don't know
Last working version (if regression)
No response
The text was updated successfully, but these errors were encountered: