これは奇妙なものであり、現時点では、マシンの構成に関係があるのではないかと考えています。
基本的に、私はかなり標準的な実装を作成しました。INotifyDataErrorInfo
特定の状況では、ErrorsChanged
イベントを発生させると、が発生しArgumentOutOfRangeException
ます。この例外には多くの情報は含まれていません。それに加えて、非負のインデックスとコレクションサイズに関するArgumentOutOfRangeException crossed a native/managed boundary
標準的な説明が表示されます。ArgumentOutOfRangeException
はInnerException
nullです。スタックトレースは次のとおりです。
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)
私が自分のマシン構成について言及する理由は、ブログに投稿されたいくつかの解決策(たとえば、こことここ)を試し、同じ問題(つまり、私のコードではなく、INotifyDataErrorInfoの別の実装)を取得したためです。私がしている問題を抱えている他の人。グーグルすると、役に立たないランダムなヒットがいくつか発生します。
必要な状態は次のとおりです。
- 検証エラーがトリガーされるように、コントロールに値を入力しました。(これは正常に機能し、エラーテキストは期待どおりにUIに表示されます)。
- 次に、検証が成功し、エラーがエラーコレクションから削除されるようにコントロールに新しい値を入力します(HasErrorsはfalseを返します)。
- この変更をエラーなしで正常に検証するためにErrorsChangedが発生し、例外が発生します。
更新:検証エラーを表示しているTextBoxからフォーカスを移動した場合にも再現できます。
サービスパック/アップデートなどを見逃したのではないかと思います。フレームワークコードにかなりの初歩的エラーがあり、同時に他の人には起こらないように見えるからです。
更新:Silverlight4の最終的なRTMビルドを使用しています。RCやベータ版ではありません。
更新:このホワイトペーパーで提供されている公式の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
更新:アプリケーションは、デバッガーが接続されていなくても(問題のあるマシンで)正常に実行され、期待どおりに動作し、未処理の例外スクリプトは呼び出されません(これはちょっと困惑しましたが、VSに関連している可能性がありますか?)。グーグルで簡単に検索して、運が悪かったのにここで光を当てる可能性のあるSilverlightプラグインログファイルを見つけることができるかどうかを確認しました。そのようなログはありますか?