PresentationFramework.dll中类型System.NullReference异常的第一次机会异常?

时间:2012-02-10 16:37:47

标签: c# wpf infragistics

我无法弄清楚我的应用程序中发生的异常。

基本上,我正在托管一个wpf用户控件,其中包含一个infragistics XamDataGrid。

当我关闭应用程序时,我得到一个无限循环的类型异常:

线程''(0x24020)已退出,代码为0(0x0)。 PresentationFramework.dll中出现类型为“System.NullReferenceException”的第一次机会异常 PresentationFramework.dll中出现类型为“System.NullReferenceException”的第一次机会异常 PresentationFramework.dll中发生了'System.NullReferenceException'类型的第一次机会异常 等等....

如果我删除XAMDATAGRID,一切正常......所以我猜测它与网格有问题......

堆栈跟踪的一部分是:(我不确定这是否有用:)

----------------------------------------------- -------------------------------------------- PresentationFramework.dll!System。 Windows.DeferredAppResourceReference.GetValue(System.Windows.BaseValueSourceInternal valueSource = Inherited)+ 0x4d bytes

WindowsBase.dll!System.Windows.DependencyObject.GetEffectiveValue(System.Windows.EntryIndex entryIndex = {System.Windows.EntryIndex},System.Windows.DependencyProperty dp = {System.Windows.DependencyProperty},System.Windows.RequestFlags请求)+ 0xe6字节

WindowsBase.dll!System.Windows.DependencyObject.GetValueEntry(System.Windows.EntryIndex entryIndex,System.Windows.DependencyProperty dp = {System.Windows.DependencyProperty},System.Windows.PropertyMetadata metadata = {System.Windows.FrameworkPropertyMetadata ,System.Windows.RequestFlags requests = FullyResolved)+ 0x2fe bytes

WindowsBase.dll!System.Windows.DependencyObject.GetValue(System.Windows.DependencyProperty dp)+ 0x48 bytes     PresentationFramework.dll!MS.Internal.Text.TextProperties.InitCommon(System.Windows.DependencyObject target = {System.Windows.Controls.TextBlock})+ 0x6b bytes     PresentationFramework.dll!MS.Internal.Text.TextProperties.TextProperties(System.Windows.FrameworkElement target = {System.Windows.Controls.TextBlock},bool isTypographyDefaultValue = true)+ 0x42 bytes
    PresentationFramework.dll!System.Windows.Controls.TextBlock.GetLineProperties()+ 0x37 bytes
    PresentationFramework.dll!System.Windows.Controls.TextBlock.EnsureTextBlockCache()+ 0x2f bytes     PresentationFramework.dll!System.Windows.Controls.TextBlock.MeasureOverride(System.Windows.Size约束)+ 0x50字节
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize)+ 0x1ee bytes
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize)+ 0x249 bytes
    PresentationFramework.dll!MS.Internal.Helper.MeasureElementWithSingleChild(System.Windows.UIElement element,System.Windows.Size约束)+ 0xfe字节
    PresentationFramework.dll!System.Windows.Controls.ContentPresenter.MeasureOverride(System.Windows.Size约束)+ 0x18字节     PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize)+ 0x1ee bytes
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize)+ 0x249 bytes
    PresentationFramework.dll!System.Windows.Controls.Control.MeasureOverride(System.Windows.Size约束)+ 0x10c bytes     PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize)+ 0x1ee bytes
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize)+ 0x249 bytes
    PresentationFramework.dll!System.Windows.Controls.StackPanel.MeasureOverride(System.Windows.Size约束)+ 0x187字节
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize)+ 0x1ee bytes
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize)+ 0x249 bytes
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureOverride(System.Windows.Size约束)+ 0x1cf bytes


如何解决这个问题的任何帮助真的很感激!谢谢!

1 个答案:

答案 0 :(得分:1)

发生错误是因为当winforms应用程序关闭时,WPF调度程序线程尚未完成为事件消息刷新挂起队列。当它开始这样做时,应用程序对象已经被关闭并被淘汰。要在托管窗口关闭之前解决,只需在WPF消息循环上调用shutdown。

Application.Current.Dispatcher.InvokeShutdown()