1

The company I work at has an old WPF .net 4.8 desktop app running in production. They are using log4net > application insights to log the errors. The errors are all there but some stacktraces seem not useful at all. What should I do so I get better stacktraces

System.NullReferenceException:
   at MS.Internal.Controls.TemplatedAdorner.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Documents.AdornerLayer.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ScrollContentPresenter.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureCell (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureCellsGroup (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ScrollViewer.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Border.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureCell (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureCellsGroup (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureCell (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureCellsGroup (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Helper.MeasureElementWithSingleChild (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ScrollContentPresenter.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureCell (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureCellsGroup (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ScrollViewer.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Helper.MeasureElementWithSingleChild (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ContentPresenter.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Control.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Helper.MeasureElementWithSingleChild (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ContentPresenter.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Border.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Control.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Helper.MeasureElementWithSingleChild (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ContentPresenter.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Control.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureCell (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureCellsGroup (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Helper.MeasureElementWithSingleChild (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ContentPresenter.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Border.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Control.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Helper.MeasureElementWithSingleChild (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ContentPresenter.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Control.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Helper.MeasureElementWithSingleChild (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ContentPresenter.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Border.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Control.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Helper.MeasureElementWithSingleChild (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ContentPresenter.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Control.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureCell (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureCellsGroup (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Helper.MeasureElementWithSingleChild (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ContentPresenter.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Border.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Control.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Helper.MeasureElementWithSingleChild (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ContentPresenter.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Control.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Grid.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Helper.MeasureElementWithSingleChild (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ContentPresenter.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Documents.AdornerDecorator.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.Border.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Window.MeasureOverrideHelper (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Window.MeasureOverride (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.MeasureCore (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.UIElement.Measure (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.ContextLayoutManager.UpdateLayout (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Media.MediaContext.RenderMessageHandler (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)

What could I do to have a more useful stacktrace or where would I start debugging this. I can't reproduce it in visualstudio. Is it possible to use reflection to find out the original calling method. Or would upgrading it to an ilogger or using serilog be helpful.

7
  • Reading the source, it looks like _child must be null. However, I have no idea why that might happen.... Are you maybe updating a UI element from a background thread or something?
    – canton7
    Commented Jul 9 at 14:11
  • Probably but the project has like a million rows of code and it happens 1 in 1000 startups or something. In debug we have been able to reproduce it once and never again so it;s some kind of race condition.
    – Joey
    Commented Jul 9 at 15:32
  • Can you log what thread that exception happens on?
    – canton7
    Commented Jul 9 at 15:39
  • The exception gets caught by the WPF unhandled exception event (Application.Current.DispatcherUnhandledException) what would be the best way to log what happens on the thread.
    – Joey
    Commented Jul 9 at 16:02
  • Ah OK, so on the UI thread. That's good (but it would have been nice if it was on a background thread, as that would have been a smoking gun)
    – canton7
    Commented Jul 11 at 8:08

1 Answer 1

1

That is the stack trace, so changing your logging provider will not affect it.

You would not be able to reproduce it in Visual Studio because it is framework code and your debugger will not break when it encounters framework exceptions by default. You can configure it so that it does by following the steps here:

https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-debug-dotnet-framework-source?view=vs-2022

4
  • I was scared of that already, It does actually break in the framework code but it does not show me what my initial code was that triggered the exception is. I can't even figure out what class it is.
    – Joey
    Commented Jul 9 at 9:21
  • It is not necessarily being triggered by your code. The exception is occurring in code computing the layout to use for one of the controls and its children. You could look at what object is null to cause the exception and why. Commented Jul 9 at 9:57
  • @canton7 I think you meant to put that comment on a different page? stackoverflow.com/questions/78720962/… Commented Jul 11 at 8:35
  • Ack, my bad thanks. Deleted.
    – canton7
    Commented Jul 11 at 8:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.