A way to handle exceptions from ValueChangedEventManager
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
WPF uses the `ValueChangedEventManager` to track .NET objects that do not implement the `INotifyPropertyChanged` interface. There is already an issue to add a runtime switch option to disable the `ValueChangedEventManager` (https://github.com/dotnet/wpf/issues/10148).
This issue is not about disabling the `ValueChangedEventManager` completely, but about being able to handle an exception when for example `Equals` (used in ``ConcurrentDictionary`2.TryGetValue``) throws an `Exception`, as in the following example, where the exception is caused by the state of COM objects:
```
System.Runtime.InteropServices.COMException (0x80040201): An event was unable to invoke any of the subscribers (0x80040201)
at UIAutomationClient.CUIAutomation8Class.IUIAutomation6_CompareElements(IUIAutomationElement el1, IUIAutomationElement el2)
at MyApp.AutomationElement.Equals(Object obj)
at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value)
at System.ComponentModel.PropertyDescriptor.RemoveValueChanged(Object component, EventHandler handler)
at MS.Internal.Data.ValueChangedEventManager.ValueChangedRecord.StopListening()
at MS.Internal.Data.ValueChangedEventManager.Purge(Object source, Object data, Boolean purgeAll)
at MS.Internal.WeakEventTable.Purge(Boolean purgeAll)
at MS.Internal.WeakEventTable.OnShutDown()
at System.Windows.Threading.Dispatcher.ShutdownImplInSecurityContext(Object state)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.Dispatcher.ShutdownImpl()
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at MyApp.Main()
```
Contributor guide
Assessment
This issue has not been assessed yet.