引发ErrorsChanged事件时的INotifyDataErrorInfo ArgumentOutOfRangeException

Sim*_*Fox 11 validation silverlight silverlight-4.0 inotifydataerrorinfo

这是一个奇怪的,在这一点上,我认为它可能与我的机器配置有关.

基本上我已经创建了一个非常标准的实现,INotifyDataErrorInfo在某些情况下,当ErrorsChanged我提出一个事件时ArgumentOutOfRangeException.此异常不包含太多信息; 它给了我ArgumentOutOfRangeException crossed a native/managed boundary加上ArgumentOutOfRangeException关于非负索引和集合大小的标准描述.该InnerException为空.堆栈跟踪如下:

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)
Run Code Online (Sandbox Code Playgroud)

我提到我的机器配置的原因是因为我尝试了一些发布到博客的解决方案(例如这里这里)并得到相同的问题(即不是我的代码,INotifyDataErrorInfo的另一个实现)并且在评论中没有提及任何其他人我遇到的问题.谷歌搜索出现了几个随机点击,没有帮助.

所需的州如下:

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

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

我有点想知道我是否错过了服务包/更新或者某些东西,因为从我看到它看起来好像框架代码中的一个非常基本的错误,同时它没有发生在其他人身上.

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

更新:我得到与本白皮书提供的官方MS样本相同的结果.

更新:我现在已经在另一台机器上测试了我的代码和提到的样本,它运行正常.我仍然真的想解决这个问题,因为它有点令人不安,因为它不适用于我的常规机器(直到现在我都没有遇到任何麻烦).关于如何追踪导致这种情况的任何建议将不胜感激.我已经在问题机器上重新安装了Silverlight(Runtime,SDK,Toolkit),但这还没有解决问题.

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

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 
Run Code Online (Sandbox Code Playgroud)

更新:应用程序运行正常(在问题机器上)没有附加调试器,按预期工作,并没有调用未处理的异常脚本(这有点让我难过,可能是VS相关吗?).我在google上进行了快速搜索,看看我是否能找到任何Silverlight插件日志文件,这可能会在这里散发一些光,没有运气,是否有这样的日志?

小智 0

我通过从 Web 项目中删除 Silverlight 应用程序链接并重新添加它们来解决此问题。

希望这可以帮助。