如何调试 "Source Not Available" WPF 错误

How to Debug "Source Not Available" WPF error

我有一个 WPF 应用程序开始失败并在启动时出现以下错误:

System.InvalidOperationException: ''{DependencyProperty.UnsetValue}' is not a valid value for property 'BorderBrush'.'

This exception was originally thrown at this call stack:
[External Code]

对于导致错误的原因,这不是很明确。我已经尝试打开 CLR 异常并按照 This Page, but it did not give any more information; I turned on the disassembly, but don't understand what it means. Turning on "Just My Code" debugging and all the Exception Settings as per this page 重新启动,在异常堆栈跟踪中得到了更多信息:

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)

但是 none 这给了我(我可以看到)关于 什么代码 失败的任何信息。我已经开始删除各种位并重新启动应用程序,但这非常耗时,我不禁想知道 - 我还应该做些什么吗?

有什么方法可以找出代码的哪一部分失败,或者任何线索(例如,要在我的代码中查找的搜索词,关于它是 .xaml 还是.cs 页面,查看异常详细信息的位置,任何可能有助于缩小位置范围的内容?例如,这是否只有在尝试覆盖 wpf 中的模板默认值失败时才会返回,或者它可能是由我的 windows 之一引起的 - 它可能来自某种样式吗?

基本上,除了看到似乎有一个地方我应该设置 BorderBrush 而不是,我不知道如何找到我需要修复的错误 - 因为它是东西丢了,不知道怎么找。任何线索、预感或建议都会收到!

这是一个 WPF Windows 应用程序,使用 .NET 4.8

在 Visual Studio 2019 中编写

原来是真的没办法查清楚哪里出错了,但是通过删除文件,清空引用,恢复的过程,才找到问题所在。

连接的 .DLL 中有一个对静态资源的引用,该引用不再存在,因为 .DLL 未经检查就重新发布。那里的名称更改意味着未找到资源,并且未设置的值已发送到依赖项 属性。如果 Microsoft 能够对有问题的资源的位置进行某种检查,那就太好了。