gpt4 book ai didi

.net - 当我在 WPF 中使用弹出窗口时出现 COMException

转载 作者:行者123 更新时间:2023-12-04 02:20:07 30 4
gpt4 key购买 nike

我有一个非常烦人的异常,当这个弹出窗口的内容似乎有很多元素时,它会卡住 WPF 抛出的我的应用程序。
在输出窗口中,我看到这个异常大约是 50 倍。

'System.Runtime.InteropServices.COMException' occurred in UIAutomationProvider.dll



然后有时在卡住后我有这个异常(exception):

ContextSwitchDeadlock was detected Message: The CLR has been unable to transition from COM context 0x3bd0048 to COM context 0x3bd01b8 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.



我的代码中没有使用任何 COM 组件,有人已经遇到过这个问题吗?

调试器检测到死锁,并且没有任何堆栈跟踪。
COM 异常堆栈跟踪是:

{"An event was unable to invoke any of the subscribers (Exception from HRESULT: 0x80040201)"}

at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)

at MS.Internal.Automation.UiaCoreProviderApi.UiaHostProviderFromHwnd(IntPtr hwnd)



当我打电话
popup.IsOpen = true

最佳答案

一个解决方案是在弹出窗口的内容上设置 Visibility="Collapsed",而不是关闭弹出窗口,但这有点hacky。

关于.net - 当我在 WPF 中使用弹出窗口时出现 COMException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1454134/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com