引发 ErrorsChanged 事件时 INotifyDataErrorInfo ArgumentOutOfRangeException

2023-11-21

这是一个奇怪的问题,此时我认为它可能与我的机器配置有关。

基本上我已经创建了一个相当标准的实现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)

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

所需状态如下:

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

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

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

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

UPDATE:我与提供的官方 MS 示例得到了相同的结果本白皮书.

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

UPDATE:以下是通过启用 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 

UPDATE:应用程序在没有附加调试器的情况下运行良好(在有问题的机器上),按预期工作,并且没有调用未处理的异常脚本(这有点让我难住了,它可能与 VS 相关吗?)。我在谷歌上进行了快速搜索,看看是否可以找到任何 Silverlight 插件日志文件,该文件可能会在这里提供一些启示,但运气不佳,有这样的日志吗?


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

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

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

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

引发 ErrorsChanged 事件时 INotifyDataErrorInfo ArgumentOutOfRangeException 的相关文章

  • HTML 表单检查空字段

    我已经在 HTML 表单中实现了输入验证 但是 如果出现任何错误 它不会提示用户 并且仍然继续将其数据发送到测试服务器 下面是我的代码
  • 如何在Silverlight中创建拉伸剪切矩形

    由于 Silverlight 控件上没有 ClipToBounds 属性这一舒适功能 因此我必须自己定义剪切形状 我想知道是否可以创建一个符合控件大小的剪切矩形 有什么建议么 如果布局中存在要动态剪辑的现有控件 则使用其SizeChange
  • Javascript onchange 事件阻止 HTML 表单中的 onsubmit 事件?

    考虑一个 HTML 表单
  • 验证电子邮件地址是否包含“@”和“.”

    我需要验证插入的电子邮件地址是否包含 和 没有正则表达式 有人能给我 java代码 和 结构图 的例子吗 I suspect你正在追求类似的东西 if address contains address contains Handle bad
  • 如何使用 Cerberus 返回自定义规则名称/错误代码?

    正在验证 csv文件 我想以用户习惯的格式给出验证结果 为了利用Cerberus https docs python cerberus org en stable index html 我让用户在一个中定义验证规则 yaml file 架构
  • LINQ2SQL:如何实现通用最大字符串长度验证?

    LINQ2SQL 中的一个常见问题是 虽然 NET 字符串允许为其变量分配任意长度 但您的数据库可能具有特定的最大长度约束 如 VARCHAR 5 这将导致 SQL 错误消息 字符串或二进制数据将被截断 这是非常没有帮助的 因为它不会告诉您
  • Silverlight UserControl 自定义属性绑定

    在 Silverlight 用户控件中实现自定义属性的正确方法是什么 从技术上讲 Silverlight 中的每个 页面 都是一个 UserControl 它们派生自 UserControl 类 当我在这里说 UserControl 时 我
  • Java,根据 WSDL 中的嵌入模式验证 XML

    我有一个 wsdl具有嵌入架构的文件 我想使用它来验证 XML 文件 字符串 wsdl文件 与验证的方式相同 xsd 该架构位于
  • 如何在 WTForms 中使字段有条件可选?

    我的表单验证工作已接近完成 我只有两种情况 我不知道具体如何解决 1 密码字段当然应该是必需的 但我还提供了通过 OAuth 使用 google 或 facebook 帐户登录的可能性 然后名称被预先填充 但我从表单中完全删除密码字段是否有
  • 带有 ObservableCollection 和动态过滤器的 Silverlight ListBox

    假设我有这门课 public class MyData public bool IsActive get set public String Data1 get set public String Data2 get set and an
  • Silverlight-当 Firefox 缩放时嵌入 html 页面时鼠标位置错误

    我们在 html 页面中嵌入了一个 Silverlight 控件 当我在 FireFox 3 5 中缩放 html 页面 ctrl 然后尝试单击 Silverlight 控件中的某些内容时 鼠标输入未在正确的位置进行 我必须单击控件上方才能
  • 使用 silverlight 4 和 c# 创建 CSV 下载

    我正在努力寻找示例或代码 以便能够在 silverlight 中创建 CSV 或文本文件作为可下载链接 我已经在 ASP net 中完成了此操作 但无法找到使用 Silverlight 的方法 我在旋转轮子吗 或者我应该创建一个 ASP 页
  • wp7 芒果中的 DataTemplateSelector

    我的应用程序中需要一个数据模板选择器 我发现这个博客 http www windowsphonegeek com articles Implementing Windows Phone 7 DataTemplateSelector and
  • Angular 模板验证表单

    我正在研究表单验证 我正在使用模板驱动的验证表单 其编码如下 现在工作正常 但是当我尝试添加时 username ngModel and password ngModel 在创建验证类的输入中 它向我显示一个错误 也请找到该错误 div c
  • 先学Silverlight还是先学WPF?

    看来 Silverlight WPF 是 NET 用户界面开发的长期未来 这很棒 因为我可以看到在客户端和 Web 开发端重用 XAML 技能的优势 但看看 WPF XAML Silverlight 它们似乎是非常庞大的技术 那么从哪里开始
  • 用于验证目的的动态查找方法

    我正在使用 Ruby on Rails 3 0 7 我想在运行时查找一些记录以进行验证 但为该查找方法传递 设置一个值 也就是说 在我的班级中 我有以下内容 class Group lt lt ActiveRecord Base valid
  • 是否可以在 Silverlight 中建立 WebSocket 连接?

    是否可以在 Silverlight 中建立 WebSocket 连接 或者如果没有 有谁知道这是否计划在未来版本中 表面上是的 事实上 它已被用来为不支持 WebSocket 的浏览器提供后备解决方案 请参阅以下内容以获取更多信息 但请注意
  • jQuery 验证日期范围问题

    我的代码中有很多地方有成对的相关开始和结束日期字段 范围 我需要验证开始日期早于结束日期 我正在使用 jQuery 验证插件 这是我的代码 http jsfiddle net jinglesthula dESz2 http jsfiddle
  • 如何验证地图中的集合

    我有一个问题 ValidJSR 303 的注释 这注解 http docs jboss org hibernate validator 4 3 reference en US html single d0e425对于普通列表或集合工作正常
  • jquery验证-等待远程检查完成

    当我打电话时 form valid 我连接了远程验证检查 一切正常 但是如果所有其他字段都有效 则表单会通过验证 因为远程检查没有 足够快 返回响应 有没有办法强制 jquery 验证等待任何远程检查完成或挂钩远程检查调用的完成事件 我目前

随机推荐