COMException when I use a Popup in WPF

11

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
.net
wpf
popup
asked on Stack Overflow Sep 21, 2009 by Nicolas Dorier • edited Aug 17, 2011 by Dave Clemmer

3 Answers

4

A solution is to make Visibility="Collapsed" on the content of the popup, instead of closing the popup, but it's a bit hacky.

answered on Stack Overflow Sep 21, 2009 by Nicolas Dorier
1

I encountered the same issue. i guess it was related to a multitouch enabled dell monitor attached to my computer. when i a stopped the Tablet Input Service, the ComExceptions disappeared. maybe this is an option for you too.

1

I fixed this problem by uninstalling a Wacom Pen and Touch tablet and disabling the Tablet Input Service. I encountered this issue with WPF Popups (TogglePopups, Comboboxes, etc) and Expanders.

answered on Stack Overflow Jan 5, 2012 by Guillaume Pinard

User contributions licensed under CC BY-SA 3.0