title: How to Debug "Source Not Available" WPF error
body: <p>I have a WPF application that has started failing with the following error at start:</p>
  <pre><code>System.InvalidOperationException: ''{DependencyProperty.UnsetValue}' is not a valid value for property 'BorderBrush'.'
  
  This exception was originally thrown at this call stack:
  [External Code]
  </code></pre>
  <p>This is not very forthcoming about what has caused the error. I have tried turning on the CLR Exceptions and restarting as per <a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/ed220be1-aaf8-4cc5-9954-8387ee07bdc3/source-not-available-when-debugging?forum=vsdebug" rel="nofollow noreferrer">This Page</a>, but it did not give any more information; I turned on the disassembly, but don't understand what it means. Turning on  &quot;Just My Code&quot; debugging and all the Exception Settings as per <a href="https://stackoverflow.com/questions/11629340/what-does-external-code-in-the-call-stack-mean">this page</a> got slightly more in the exception stack trace:</p>
  <pre><code>System.InvalidOperationException
  HResult=0x80131509
  Message='{DependencyProperty.UnsetValue}' is not a valid value for property 'BorderBrush'.
  Source=WindowsBase
  StackTrace: at System.Windows.DependencyObject.GetEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, 
  RequestFlags requests)
  
  This exception was originally thrown at this call stack:
  System.Windows.DependencyObject.GetEffectiveValue(System.Windows.EntryIndex, System.Windows.DependencyProperty, System.Windows.RequestFlags)
  </code></pre>
  <p>but none of this gives me (that I can see) any information about <em>what code</em> is failing. I have got down to deleting various bits and re-starting the app, but it is extremely time-consuming and I can't help but wonder - is there something else I should be doing.</p>
  <p>Is there any way I can find out which bit of code is failing, or any clues (e.g. search terms to look for in my code, clues as to whether it would be a .xaml or a .cs page, places to look in the Exception details, anything) that might help narrow down the location? For instance, is this something that would only be returned by a failed attempt to override the template defaults in wpf, or might it be caused by one of my windows - Is it likely to have come from a style maybe?</p>
  <p>Basically, other than seeing that there seems to be a place where I should be setting the <code>BorderBrush</code> and am not, I have no idea how to find what error I need to fix - and since it is a missing thing, I don't know how to find it. Any leads, hunches or advice will be greatly received!</p>
  <p>This is a WPF Windows Application, writing in Visual Studio 2019 using .NET 4.8</p>