小编wil*_*mvn的帖子

WPF Freezable漏洞的解决方法?

我最近遇到了一个非常糟糕的WPF错误.我认为它与Microsoft Connect上的这个错误相同.

我们的应用程序使用Visual Studio 2010定位.NET 4.0 Client Profile.

基本上,当ViewModel触发对任何导致项目在ItemsControl中移动的属性或集合的更改时,可能会抛出下面的异常.它并不总是发生,似乎是基于不同时间的不同触发器而发生的.在启动应用程序后不久,它似乎更有可能.如果您可以使用它几分钟而不会遇到异常,那么您可能永远不会在该应用程序实例期间遇到它.

就像Connect错误报告一样,我正在使用来自a的{DynamicResource key}加载SolidColorBrushes ResourceDictionary.一些字典是手动加载的(用于支持).我尝试手动冻结这些词典中的所有内容,但似乎没有帮助.

最近,当我向UserControl主窗口添加了几个s并将其中的ItemsControls绑定到ObservableCollections 时,异常变得更加频繁.以前,我只看到50次中的1次异常,但现在我看到它使用该程序的5次中有4次.

有没有人有任何解决方法的想法?Connect错误表明这可能会在下一个.NET版本中修复(无论何时),但是这个错误使我们的应用程序现在基本上无法使用.

    System.InvalidOperationException: Specified value of type 'System.Windows.Media.SolidColorBrush' must have IsFrozen set to false to modify.
       at System.Windows.Freezable.WritePreamble()
       at System.Windows.Freezable.remove_Changed(EventHandler value)
       at System.Windows.ResourceReferenceExpression.ResourceReferenceExpressionWeakContainer.RemoveChangedHandler()
       at System.Windows.ResourceReferenceExpression.ResourceReferenceExpressionWeakContainer.InvalidateTargetSubProperty(Object sender, EventArgs args)
       at System.Windows.Freezable.FireChanged()
       at System.Windows.Freezable.Freeze(Boolean isChecking)
       at System.Windows.Freezable.Freeze()
       at System.Windows.Freezable.System.Windows.ISealable.Seal()
       at System.Windows.StyleHelper.SealIfSealable(Object value)
       at System.Windows.StyleHelper.GetChildValueHelper(UncommonField`1 dataField, ItemStructList`1& valueLookupList, DependencyProperty dp, DependencyObject container, FrameworkObject child, Int32 childIndex, Boolean styleLookup, EffectiveValueEntry& …

.net wpf .net-4.0 freezable

28
推荐指数
1
解决办法
1万
查看次数

标签 统计

.net ×1

.net-4.0 ×1

freezable ×1

wpf ×1