Как отследить исключение WPF NotSupportedException, созданное потоком рендеринга?
Я работаю над WPF-приложением смешанного режима (C#,C++,C++/CLI), для которого мы получаем случайные отчеты о сбоях от клиентов с CLR System.NotSupportedException "Не было найдено информации об этом пиксельном формате" и смешанного стека вызовов, аналогичного (немного сокращен и методы приложения переименованы):
PresentationCore.dll!System.Windows.Media.PixelFormat.CreatePixelFormatInfo() Zeile 468 C#
PresentationCore.dll!System.Windows.Media.PixelFormat.InternalBitsPerPixel.get() Zeile 494 C#
PresentationCore.dll!System.Windows.Media.Imaging.BitmapSource.GetClosestDUCEFormat(System.Windows.Media.PixelFormat format, System.Windows.Media.Imaging.BitmapPalette palette) Unbekannt
PresentationCore.dll!System.Windows.Media.Imaging.BitmapSource.DUCECompatiblePtr.get() Zeile 826 C#
PresentationCore.dll!System.Windows.Media.Imaging.BitmapSource.UpdateBitmapSourceResource(System.Windows.Media.Composition.DUCE.Channel channel, bool skipOnChannelCheck) Zeile 713 C#
PresentationCore.dll!System.Windows.Media.Imaging.BitmapSource.UpdateResource(System.Windows.Media.Composition.DUCE.Channel channel, bool skipOnChannelCheck) Zeile 740 C#
PresentationCore.dll!System.Windows.Media.Imaging.BitmapSource.AddRefOnChannelCore(System.Windows.Media.Composition.DUCE.Channel channel) Zeile 140 C#
PresentationCore.dll!System.Windows.Media.Imaging.BitmapSource.System.Windows.Media.Composition.DUCE.IResource.AddRefOnChannel(System.Windows.Media.Composition.DUCE.Channel channel) Zeile 666 C#
PresentationCore.dll!System.Windows.Media.RenderData.System.Windows.Media.Composition.DUCE.IResource.AddRefOnChannel(System.Windows.Media.Composition.DUCE.Channel channel) Zeile 869 C#
PresentationCore.dll!System.Windows.UIElement.RenderContent(System.Windows.Media.RenderContext ctx, bool isOnChannel) Zeile 5743 C#
PresentationCore.dll!System.Windows.Media.Visual.RenderRecursive(System.Windows.Media.RenderContext ctx) Zeile 1243 C#
PresentationCore.dll!System.Windows.Media.Visual.UpdateChildren(System.Windows.Media.RenderContext ctx, System.Windows.Media.Composition.DUCE.ResourceHandle handle) Zeile 1695 C#
PresentationCore.dll!System.Windows.Media.Visual.RenderRecursive(System.Windows.Media.RenderContext ctx) Zeile 1248 C#
PresentationCore.dll!System.Windows.Media.Visual.UpdateChildren(System.Windows.Media.RenderContext ctx, System.Windows.Media.Composition.DUCE.ResourceHandle handle) Zeile 1695 C#
PresentationCore.dll!System.Windows.Media.Visual.RenderRecursive(System.Windows.Media.RenderContext ctx) Zeile 1248 C#
... lots of similar
PresentationCore.dll!System.Windows.Media.Visual.UpdateChildren(System.Windows.Media.RenderContext ctx, System.Windows.Media.Composition.DUCE.ResourceHandle handle) Zeile 1695 C#
PresentationCore.dll!System.Windows.Media.Visual.RenderRecursive(System.Windows.Media.RenderContext ctx) Zeile 1248 C#
PresentationCore.dll!System.Windows.Media.Visual.UpdateChildren(System.Windows.Media.RenderContext ctx, System.Windows.Media.Composition.DUCE.ResourceHandle handle) Zeile 1695 C#
PresentationCore.dll!System.Windows.Media.Visual.RenderRecursive(System.Windows.Media.RenderContext ctx) Zeile 1248 C#
PresentationCore.dll!System.Windows.Media.Visual.Render(System.Windows.Media.RenderContext ctx, uint childIndex) Zeile 1199 C#
PresentationCore.dll!System.Windows.Media.CompositionTarget.Compile(System.Windows.Media.Composition.DUCE.Channel channel) Zeile 68 C#
PresentationCore.dll!System.Windows.Media.CompositionTarget.System.Windows.Media.ICompositionTarget.Render(bool inResize, System.Windows.Media.Composition.DUCE.Channel channel) Zeile 181 C#
PresentationCore.dll!System.Windows.Media.MediaContext.Render(System.Windows.Media.ICompositionTarget resizedCompositionTarget) Zeile 866 C#
PresentationCore.dll!System.Windows.Media.MediaContext.RenderMessageHandlerCore(object resizedCompositionTarget) Zeile 940 C#
PresentationCore.dll!System.Windows.Media.MediaContext.RenderMessageHandler(object resizedCompositionTarget) Zeile 903 C#
PresentationCore.dll!System.Windows.Media.MediaContext.Resize(System.Windows.Media.ICompositionTarget resizedCompositionTarget) Zeile 995 C#
PresentationCore.dll!System.Windows.Interop.HwndTarget.OnResize() Zeile 629 C#
PresentationCore.dll!System.Windows.Interop.HwndTarget.HandleMessage(MS.Internal.Interop.WindowMessage msg, System.IntPtr wparam, System.IntPtr lparam) Zeile 387 C#
PresentationCore.dll!System.Windows.Interop.HwndSource.HwndTargetFilterMessage(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Zeile 511 C#
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Zeile 230 C#
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) Zeile 121 C#
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Zeile 85 C#
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Zeile 108 C#
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Zeile 767 C#
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Zeile 222 C#
[Übergang von Systemeigen zu Verwaltet]
[Übergang von Verwaltet zu Systemeigen]
WindowsBase.dll!MS.Win32.HwndSubclass.DefWndProcWrapper(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Zeile 106 C#
[Übergang von Systemeigen zu Verwaltet]
[Übergang von Verwaltet zu Systemeigen]
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Zeile 235 C#
[Übergang von Systemeigen zu Verwaltet]
[Übergang von Verwaltet zu Systemeigen]
WindowsBase.dll!System.Windows.Threading.DispatcherSynchronizationContext.Wait(System.IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout) Zeile 74 C#
mscorlib.dll!System.Threading.SynchronizationContext.InvokeWaitMethodHelper(System.Threading.SynchronizationContext syncContext, System.IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout) Zeile 74 C#
[Übergang von Systemeigen zu Verwaltet]
[Übergang von Verwaltet zu Systemeigen]
mscorlib.dll!System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext) Zeile 81 C#
mscorlib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext) Unbekannt
System.dll!System.Net.FileWebRequest.GetResponse() Zeile 355 C#
PresentationCore.dll!MS.Internal.WpfWebRequestHelper.GetResponse(System.Net.WebRequest request) Zeile 154 C#
PresentationCore.dll!System.Windows.Media.ColorContext.Initialize(System.Uri profileUri, bool isStandardProfileUriNotFromUser) Zeile 426 C#
PresentationCore.dll!System.Windows.Media.ColorContext.ColorContext(System.Windows.Media.PixelFormat pixelFormat) Zeile 59 C#
PresentationCore.dll!System.Windows.Media.Imaging.BitmapImage.FinalizeCreation() Zeile 477 C#
PresentationCore.dll!System.Windows.Media.Imaging.BitmapSource.CompleteDelayedCreation() Zeile 193 C#
PresentationCore.dll!System.Windows.Media.Imaging.BitmapSource.PixelWidth.get() Zeile 947 C#
[Übergang von Systemeigen zu Verwaltet]
[Übergang von Verwaltet zu Systemeigen]
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.GetValue(object item, int level) Zeile 397 C#
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.RawValue(int k) Zeile 773 C#
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.RawValue() Zeile 745 C#
PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.RawValue() Zeile 368 C#
PresentationFramework.dll!System.Windows.Data.BindingExpression.TransferValue(object newValue, bool isASubPropertyChange) Zeile 1346 C#
PresentationFramework.dll!System.Windows.Data.BindingExpression.ScheduleTransfer(bool isASubPropertyChange) Zeile 1241 C#
PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.NewValueAvailable(bool dependencySourcesChanged, bool initialValue, bool isASubPropertyChange) Zeile 206 C#
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(int k, System.ComponentModel.ICollectionView collectionView, object newValue, bool isASubPropertyChange) Zeile 1210 C#
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.OnDependencyPropertyChanged(System.Windows.DependencyObject d, System.Windows.DependencyProperty dp, bool isASubPropertyChange) Zeile 689 C#
PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.OnSourceInvalidation(System.Windows.DependencyObject d, System.Windows.DependencyProperty dp, bool isASubPropertyChange) Zeile 294 C#
PresentationFramework.dll!System.Windows.Data.BindingExpression.HandlePropertyInvalidation(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs args) Zeile 889 C#
PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.OnPropertyInvalidation(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs args) Zeile 1030 C#
PresentationFramework.dll!System.Windows.Data.BindingExpression.OnPropertyInvalidation(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs args) Zeile 1109 C#
WindowsBase.dll!System.Windows.DependentList.InvalidateDependents(System.Windows.DependencyObject source, System.Windows.DependencyPropertyChangedEventArgs sourceArgs) Zeile 68 C#
WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) Zeile 815 C#
WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType) Zeile 1558 C#
WindowsBase.dll!System.Windows.DependencyObject.InvalidateProperty(System.Windows.DependencyProperty dp, bool preserveCurrentValue) Zeile 709 C#
PresentationFramework.dll!System.Windows.StyleHelper.InvalidateDependents(System.Windows.Style ownerStyle, System.Windows.FrameworkTemplate frameworkTemplate, System.Windows.DependencyObject container, System.Windows.DependencyProperty dp, ref MS.Utility.FrugalStructList<System.Windows.ChildPropertyDependent> dependents, bool invalidateOnlyContainer) Zeile 1485 C#
PresentationFramework.dll!System.Windows.StyleHelper.OnTriggerSourcePropertyInvalidated(System.Windows.Style ownerStyle, System.Windows.FrameworkTemplate frameworkTemplate, System.Windows.DependencyObject container, System.Windows.DependencyProperty dp, System.Windows.DependencyPropertyChangedEventArgs changedArgs, bool invalidateOnlyContainer, ref MS.Utility.FrugalStructList<MS.Utility.ItemStructMap<System.Windows.TriggerSourceRecord>> triggerSourceRecordFromChildIndex, ref MS.Utility.FrugalMap propertyTriggersWithActions, int sourceChildIndex) Zeile 1880 C#
PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) Zeile 2810 C#
WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) Zeile 798 C#
WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType) Zeile 1558 C#
WindowsBase.dll!System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty dp, object value, System.Windows.PropertyMetadata metadata, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType, bool isInternal) Zeile 1368 C#
WindowsBase.dll!System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty dp, object value) Zeile 1237 C#
MyButton.UpdateButton() Unbekannt
MyButton.OnAnyChange(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) Unbekannt
WindowsBase.dll!System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) Zeile 902 C#
PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) Zeile 2782 C#
WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) Zeile 798 C#
WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType) Zeile 1558 C#
WindowsBase.dll!System.Windows.DependencyObject.InvalidateProperty(System.Windows.DependencyProperty dp, bool preserveCurrentValue) Zeile 709 C#
PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.Invalidate(bool isASubPropertyChange) Zeile 821 C#
PresentationFramework.dll!System.Windows.Data.BindingExpression.TransferValue(object newValue, bool isASubPropertyChange) Zeile 1462 C#
PresentationFramework.dll!System.Windows.Data.BindingExpression.ScheduleTransfer(bool isASubPropertyChange) Zeile 1241 C#
PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.NewValueAvailable(bool dependencySourcesChanged, bool initialValue, bool isASubPropertyChange) Zeile 206 C#
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(int k, System.ComponentModel.ICollectionView collectionView, object newValue, bool isASubPropertyChange) Zeile 1210 C#
PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(object o, string propName) Zeile 319 C#
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) Zeile 716 C#
WindowsBase.dll!System.Windows.WeakEventManager.ListenerList<System.ComponentModel.PropertyChangedEventArgs>.DeliverEvent(object sender, System.EventArgs e, System.Type managerType) Zeile 589 C#
WindowsBase.dll!System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs args) Zeile 157 C#
MyDataModel.Something.set(int value) Unbekannt
...
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) Zeile 35 C#
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised) Zeile 181 C#
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender, System.Windows.RoutedEventArgs args) Zeile 5435 C#
PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs e) Zeile 5403 C#
PresentationFramework.dll!System.Windows.Controls.MenuItem.InvokeClickAfterRender(object arg) Zeile 357 C#
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Zeile 85 C#
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Zeile 108 C#
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() Zeile 225 C#
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(object state) Zeile 238 C#
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Zeile 364 C#
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Zeile 337 C#
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Zeile 331 C#
WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Zeile 96 C#
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke() Zeile 133 C#
WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue() Zeile 817 C#
WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Zeile 1260 C#
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Zeile 230 C#
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) Zeile 121 C#
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Zeile 85 C#
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Zeile 108 C#
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Zeile 767 C#
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Zeile 222 C#
[Übergang von Systemeigen zu Verwaltet]
[Übergang von Verwaltet zu Systemeigen]
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) Zeile 922 C#
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame frame) Zeile 908 C#
PresentationFramework.dll!System.Windows.Window.ShowHelper(object booleanBox) Zeile 2473 C#
PresentationFramework.dll!System.Windows.Window.Show() Zeile 2333 C#
PresentationFramework.dll!System.Windows.Window.ShowDialog() Zeile 2388 C#
MyApp.Main(string[] args) Unbekannt
[Übergang von Systemeigen zu Verwaltet]
К сожалению, мы не можем воспроизвести эту проблему надежно, но мы воспроизводили ее время от времени. Это кажется очень чувствительным к срокам.
Проблема возникает в различных версиях.NET 4, в том числе в последних версиях Windows 10 (например, clr.dll версии 4.6.1073.0).
Что вызывает у меня подозрение, так это то, что один и тот же (!) Экземпляр BitmapSource появляется дважды в стеке вызовов. Первый вызов (BitmapSource.PixelWidth.get()) приводит к операции ожидания, во время которой обрабатывается сообщение Windows, что приводит к выполнению некоторого кода рендеринга, что в конечном итоге вызывает дальнейшие вызовы для того же экземпляра BitmapSource.
Действительно ли этот вид повторного входа поддерживается или это может быть ошибкой в .NET Framework? Наличие некоторой асинхронной обработки сообщений объясняет, почему это так сложно воспроизвести.
Любая помощь с благодарностью!