【发布时间】:2012-05-25 15:26:28
【问题描述】:
所以我有一个控件,它响应它的项目被更改,调用 UpdateLayout()。这导致堆栈跟踪如下所示:
描述:应用程序请求进程终止通过 System.Environment.FailFast(字符串消息)。消息:不可恢复 系统错误。堆栈:在 System.Environment.FailFast(System.String) 在 MS.Internal.Invariant.FailFast(System.String, System.String) 在 MS.Internal.Invariant.Assert(Boolean, System.String) 在 System.Windows.Window.GetWindowMinMax() 在 System.Windows.Window.MeasureOverride(System.Windows.Size) 在 System.Windows.FrameworkElement.MeasureCore(System.Windows.Size) 在 System.Windows.UIElement.Measure(System.Windows.Size) 在 System.Windows.ContextLayoutManager.UpdateLayout() 在 System.Windows.UIElement.UpdateLayout() 在
显然,在某些情况下,GetWindowMinMax() 会导致某种 Assert() 失败,从而导致调用 Environment.FailFast。在调用 UpdateLayout 之前,我可以检查哪些条件以确保不会出现这些情况以避免遇到此错误?
【问题讨论】:
标签: .net wpf error-handling