引发 ErrorsChanged 事件时 INotifyDataErrorInfo ArgumentOutOfRangeException [英] INotifyDataErrorInfo ArgumentOutOfRangeException when raising ErrorsChanged event

查看:16
本文介绍了引发 ErrorsChanged 事件时 INotifyDataErrorInfo ArgumentOutOfRangeException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个奇怪的问题,此时我想这可能与我的机器配置有关.

This is a wierd one and at this point I am thinking that it may have something to do with my machines configuration.

基本上,我已经创建了一个非常标准的 INotifyDataErrorInfo 实现,在某些情况下,当引发 ErrorsChanged 事件时,我得到一个 ArgumentOutOfRangeException.此异常不包含太多信息;它给了我 ArgumentOutOfRangeException 越过本机/托管边界 加上关于非负索引和集合大小的标准 ArgumentOutOfRangeException 描述.InnerException 为空.堆栈跟踪如下:

Basically I have created a pretty standard implementation of INotifyDataErrorInfo and in certain circumstances, when raising the ErrorsChanged event I get an ArgumentOutOfRangeException. This exception doesn't contain much info; it gives me ArgumentOutOfRangeException crossed a native/managed boundary plus the standard ArgumentOutOfRangeException description regarding non-negative indexes and collection sizes. The InnerException is null. The stack trace is as follows:

at System.ThrowHelper
        .ThrowArgumentOutOfRangeException(ExceptionArgument argument,
                                           ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Collections.ObjectModel.Collection`1.get_Item(Int32 index)
at System.Collections.ObjectModel.ReadOnlyCollection`1.get_Item(Int32 index)

我提到我的机器配置的原因是因为我尝试了几个发布到博客的解决方案(例如 此处here) 并得到同样的问题(即不是我的代码,INotifyDataErrorInfo 的另一个实现)并且在评论中没有提到任何其他人遇到我做的问题.谷歌搜索会发现一些无济于事的随机点击.

The reason I mention my machine configuration is because I have tried a couple of solutions posted to blogs (e.g. here and here) and get the same problem (i.e. not my code, another implementation of INotifyDataErrorInfo) and there is no mention in the comments of any others getting the problem I do. Googling turns up a couple of random hits that don't help.

需要的状态如下:

  1. 我在控件中输入了一个值,以便触发验证错误.(这工作正常,错误文本按预期显示在 UI 中).
  2. 然后我在控件中输入一个新值,以便验证成功并从错误集合中删除错误(HasErrors 返回 false).
  3. 引发 ErrorsChanged 以反映此更改为成功验证且没有错误,并且发生异常.

更新:如果我将焦点从显示验证错误的文本框移开,我也可以重现.

UPDATE: I can also reproduce if I move focus away from a TextBox displaying a validation error.

我有点想知道我是否错过了服务包/更新或其他东西,因为从我所看到的情况来看,框架代码中似乎有一个非常基本的错误,同时它没有发生其他.

I'm kind of wondering if I've missed a service pack/update or something because from what I'm seeing it looks as though theres a pretty elementary error in the framework code and at the same time its not happening for others.

更新:我使用的是 Silverlight 4 的最终 RTM 版本.不是 RC 或 Beta.

更新:我得到了与 本白皮书.

更新:我现在已经在另一台机器上测试了我的代码和提到的示例,它工作正常.我仍然很想解决这个问题,因为它不能在我的常规机器上工作(到目前为止我还没有遇到任何问题),这有点令人不安.任何有关我如何追踪导致这种情况的原因的建议都将不胜感激.我在有问题的机器上重新安装了 Silverlight(运行时、SDK、工具包),但这并没有解决问题.

UPDATE: I have now tested my code and the mentioned samples on another machine and it works fine. I would still really like to resolve this as its a little unsettling that it isn't working on my regular machine (which I have not had any trouble with up until now). Any suggestions as to how I could track down what is causing this would be appreciated. I have re-installed Silverlight (Runtime, SDK, Toolkit) on the problem machine and this has not resolved the issue.

更新:这是通过启用MS符号服务器的源服务器支持获得的发生异常的框架代码的调用堆栈:

UPDATE: Here is the call stack of the framework code where the exception is occurring obtained by enabling source server support with MS symbol server:

mscorlib.dll!System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument argument, System.ExceptionResource resource) + 0x40 bytes 
  mscorlib.dll!System.ThrowHelper.ThrowArgumentOutOfRangeException() + 0x10 bytes 
  mscorlib.dll!System.Collections.Generic.List<System.Windows.Controls.ValidationError>.this[int].get(int index = 0) + 0x13 bytes 
  mscorlib.dll!System.Collections.ObjectModel.Collection<System.Windows.Controls.ValidationError>.this[int].get(int index) + 0x2e bytes 
  mscorlib.dll!System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.Controls.ValidationError>.this[int].get(int index) + 0x2e bytes 
  [Native to Managed Transition] 
  [Managed to Native Transition] 
  System.Windows.dll!System.Windows.IndexerListener.Value.get() + 0xc3 bytes 
  System.Windows.dll!System.Windows.IndexerPathStep.Value.get() + 0x17 bytes 
  System.Windows.dll!System.Windows.PropertyPathListener.RaisePropertyPathStepChanged(System.Windows.PropertyPathStep source = {System.Windows.IndexerPathStep}) + 0x17 bytes 
  System.Windows.dll!System.Windows.IndexerPathStep.RaisePropertyPathStepChanged(System.Windows.PropertyListener source) + 0xe bytes 
  System.Windows.dll!System.Windows.IndexerListener.SourcePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs args) + 0xea bytes 
  System.Windows.dll!System.Windows.Data.WeakPropertyChangedListener.PropertyChangedCallback(object sender, System.ComponentModel.PropertyChangedEventArgs args) + 0x3d bytes 
  System.Windows.dll!System.Collections.ObjectModel.ReadOnlyObservableCollection<System.__Canon>.OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs args) + 0x17 bytes 
  System.Windows.dll!System.Collections.ObjectModel.ReadOnlyObservableCollection<System.__Canon>.HandlePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + 0xe bytes 
  System.Windows.dll!System.Collections.ObjectModel.ObservableCollection<System.Windows.Controls.ValidationError>.OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e) + 0x37 bytes 
  System.Windows.dll!System.Collections.ObjectModel.ObservableCollection<System.Windows.Controls.ValidationError>.RemoveItem(int index = 0) + 0x79 bytes 
  mscorlib.dll!System.Collections.ObjectModel.Collection<System.Windows.Controls.ValidationError>.Remove(System.Windows.Controls.ValidationError item) + 0x75 bytes 
  System.Windows.dll!System.Windows.Controls.Validation.RemoveValidationError(System.Windows.FrameworkElement fe = {System.Windows.Controls.TextBox}, System.Windows.Controls.ValidationError error) + 0x40 bytes 
  System.Windows.dll!System.Windows.Data.BindingExpression.RemoveErrorFromTarget(System.Windows.Controls.ValidationError error) + 0x48 bytes 
  System.Windows.dll!System.Windows.Data.BindingExpression.NotifyOldDataErrorInfos(System.Collections.ObjectModel.Collection<System.Windows.Controls.ValidationError> validationErrors) + 0x73 bytes 
  System.Windows.dll!System.Windows.Data.BindingExpression.NotifyOldDataErrorInfos(bool isNotifyChildDataErrorInfo) + 0x25 bytes 
  System.Windows.dll!System.Windows.Data.BindingExpression.NotifyDataErrorInfo_ErrorsChanged(object sender, System.ComponentModel.DataErrorsChangedEventArgs e) + 0xad bytes 

更新: 应用程序在没有附加调试器的情况下运行良好(在有问题的机器上),按预期工作,并且没有调用未处理的异常脚本(这让我感到困惑,这可能与 VS 相关吗?).我在 google 上进行了快速搜索,看看是否可以找到任何 Silverlight 插件日志文件,如果没有运气,这些文件可能会在这里有所启发,是否有这样的日志?

UPDATE: The application runs fine (on the problem machine) without a debugger attached, works as expected and no unhandled exception scripts are invoked (This kinda had me stumped, could it be VS related?). I had a quick search on google to see if I could find any Silverlight plugin log file which may shed some light here with no luck, is there such a log?

推荐答案

我认为是TextBox模板工具提示中的绑定错误

I think it is binding error in TextBox template tooltip

{Binding (Validation.Errors)[0].ErrorContent}

Validation.Errors 变为空但绑定仍未更新其引用.

Validation.Errors become empty but binding still has not updated its references.

我建议忽略异常.在调试设置中取消选中当异常跨 AppDomain 或托管时中断....".

I recommend to ignore the exception. Uncheck "Break when exceptions cross AppDomain or managed...." in Debugging settings.

这篇关于引发 ErrorsChanged 事件时 INotifyDataErrorInfo ArgumentOutOfRangeException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆