Exception:CoreWebView2Controller members can only be accessed from the UI thread.无法将类型为“System.__ComObject”的 COM 对象强制转换为接口类型“Microsoft.Web.WebView2.Core.Raw.ICoreWebView2Controller”。此操作失败的原因是对 IID 为“{4D00C0D1-9434-4EB6-8078-8697A560334F}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: 不支持此接口 (异常来自 HRESULT:0x80004002 (E_NOINTERFACE))。

报错信息

InvalidOperationException: CoreWebView2Controller members can only be accessed from the UI thread.
StackTrace:
   在 Microsoft.Web.WebView2.Wpf.WebView2Base.SafeAccessController(Action action)
   在 Microsoft.Web.WebView2.Wpf.WebView2.OnWindowPositionChanged(Rect rcBoundingBox)
   在 System.Windows.Interop.HwndHost.UpdateWindowPos()
   在 System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
   在 System.Windows.ContextLayoutManager.UpdateLayout()
   在 System.Windows.Interop.HwndSource.Process_WM_SIZE(UIElement rootUIElement, IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam)
   在 System.Windows.Interop.HwndSource.LayoutFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

InvalidCastException: 无法将类型为“System.__ComObject”的 COM 对象强制转换为接口类型“Microsoft.Web.WebView2.Core.Raw.ICoreWebView2Controller”。此操作失败的原因是对 IID 为“{4D00C0D1-9434-4EB6-8078-8697A560334F}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: 不支持此接口 (异常来自 HRESULT:0x80004002 (E_NOINTERFACE))。
StackTrace:
   在 System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
   在 Microsoft.Web.WebView2.Core.Raw.ICoreWebView2Controller.set_Bounds(tagRECT Bounds)
   在 Microsoft.Web.WebView2.Core.CoreWebView2Controller.set_Bounds(Rectangle value)

 

解决方法

暂无解决方案。

相关信息
1 查看
7天23小时前
Quicker版本
版本 反馈次数
1.44.22 1