How to handle a render exception in Windows Presentation Framework (WPF)

1

Randomly, my system causes this exception (which I only see because of the logs left in Windows events). It is an application that runs 24 hours a day every day. When the error occurs, the screen freezes and if I click anything, the program closes with the Windows error message.

I have already implemented a memory management with the GC, but apparently this is not the problem.

The point in question is that I can not find where the problem is, since I have debugged the entire project, I have done unit tests and everything runs perfectly, in addition to my understanding, these classes are from the .NET Framework itself, more specifically of the rendering part.

Every time it occurs, though it is difficult to do, it's the same exception, and I do not know how to handle it.

How can I identify the source of this problem or handle this exception? If there was a way to only handle the exception so that the application would not crash would already help.

Aplicativo: StreamWpf.exe
Versão do Framework: v4.0.30319
Descrição: O processo foi terminado devido a uma exceção sem tratamento.
Informações da Exceção: System.Runtime.InteropServices.COMException
Pilha:
   em System.Windows.Media.Composition.DUCE+Channel.SyncFlush()
   em System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean, System.Nullable'1<ChannelSet>)
   em System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr)
   em System.Windows.Interop.HwndTarget.HandleMessage(MS.Internal.Interop.WindowMessage, IntPtr, IntPtr)
   em System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   em MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   em MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   em System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   em MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   em System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   em MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   em MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
   em MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr, Int32, IntPtr, IntPtr)
   em MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
   em MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   em MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
   em MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr, Int32, IntPtr, IntPtr)
   em MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
   em MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   em MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   em System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   em System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
   em System.Windows.Threading.Dispatcher.Run()
   em System.Windows.Application.RunDispatcher(System.Object)
   em System.Windows.Application.RunInternal(System.Windows.Window)
   em System.Windows.Application.Run(System.Windows.Window)
   em StreamWpf.App.Main()

Nome do aplicativo com falha: StreamWpf.exe, versão: 2.0.0.0, carimbo de data/hora: 0x5981bd3b
Nome do módulo com falha: KERNELBASE.dll, versão: 6.2.9200.16864, carimbo de data/hora: 0x531d2c84
Código de exceção: 0xe0434352
Deslocamento da falha: 0x00011a65
ID do processo com falha: 0xf28
Hora de início do aplicativo com falha: 0x01d30d1967a85ab5
Caminho do aplicativo com falha: C:\Program Files\Stx\StreamWpf.exe
Caminho do módulo com falha: C:\Windows\system32\KERNELBASE.dll
ID do Relatório: abd4667b-8273-11e7-afa6-0019b9fb11aa
Nome completo do pacote com falha: 
ID do aplicativo relativo ao pacote com falha: 
    
asked by anonymous 16.08.2017 / 13:41

1 answer

1

Talk Renan, if I told you that I spent the day with this same problem heheh.

Well what I got was to use this:

AppDomain.CurrentDomain.UnhandledException += (sender, e) => MessageBox.Show(e.ExceptionObject.ToString());

In MainWindow of my application and yes yes go treating each problem, see if it helps you.

    
18.08.2017 / 13:44