I have a very annoying exception which freeze my application thrown by WPF, when the content of this popup seems to have to much element.
In the output windows I see approximatively 50 times this exception.
‘System.Runtime.InteropServices.COMException’
occurred in UIAutomationProvider.dll
Then sometimes after the freeze I have this 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.
I don’t use any COM component in my code, does someone already had this problem ?
The Deadlock is detected by the debugger and doesn’t have any stacktrace.
The COM Exception stacktrace is :
{“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)
When I call
popup.IsOpen = true
A solution is to make Visibility=”Collapsed” on the content of the popup, instead of closing the popup, but it’s a bit hacky.