MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: Exception on Dispose() of WPF WebView2 control
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.