11

これは奇妙なものであり、現時点では、マシンの構成に関係があるのではないかと考えています。

基本的に、私はかなり標準的な実装を作成しました。INotifyDataErrorInfo特定の状況では、ErrorsChangedイベントを発生させると、が発生しArgumentOutOfRangeExceptionます。この例外には多くの情報は含まれていません。それに加えて、非負のインデックスとコレクションサイズに関するArgumentOutOfRangeException crossed a native/managed boundary標準的な説明が表示されます。ArgumentOutOfRangeExceptionInnerExceptionnullです。スタックトレースは次のとおりです。

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の別の実装)を取得したためです。私がしている問題を抱えている他の人。グーグルすると、役に立たないランダムなヒットがいくつか発生します。

必要な状態は次のとおりです。

  1. 検証エラーがトリガーされるように、コントロールに値を入力しました。(これは正常に機能し、エラーテキストは期待どおりにUIに表示されます)。
  2. 次に、検証が成功し、エラーがエラーコレクションから削除されるようにコントロールに新しい値を入力します(HasErrorsはfalseを返します)。
  3. この変更をエラーなしで正常に検証するために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プラグインログファイルを見つけることができるかどうかを確認しました。そのようなログはありますか?

4

3 に答える 3

3

TextBox テンプレート ツールチップのバインド エラーだと思います

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

Validation.Errors は空になりますが、バインディングは参照を更新していません。

例外を無視することをお勧めします。デバッグ設定で「例外が AppDomain または管理対象を超えると中断する....」のチェックを外します。

于 2011-04-14T14:59:43.753 に答える
0

この問題は、SilverlightアプリケーションリンクをWebプロジェクトから削除し、再度追加することで修正できました。

お役に立てれば。

于 2010-10-14T12:02:14.763 に答える
0

この状況でネイティブ コードからスローされる可能性のある例外が 2 つあります。どちらも、catch に何を入れても (または入れなくても)、try...catch ブロックによってもキャッチされません。

1 つは、「ArgumentOutOfRangeException がネイティブ/マネージド境界を超えました」です。これを表示しないようにするには、[ツール] > [オプション] > [デバッグ] > [全般] で [例外が AppDomain またはマネージド/ネイティブの境界を超えると中断する (マネージドのみ)] のチェックを外す必要があります。

もう 1 つは "ArgumentOutOfRangeException" です。これを表示しないようにするには、[ツール] > [オプション] > [デバッグ] > [全般] で [マイ コードのみを有効にする] をオンにする必要があります。

于 2013-09-24T19:01:58.863 に答える