0

の顧客レポートがありますIndexOutOfRangeExceptionが、それが報告された行番号にはアレイアクセスがありません!行の形式は次のとおりです。

using (XyzConnection conn = new XyzConnection(anObject.aProperty.anotherProperty))

XyzConnection、、anObjectなどは置き換えられた名前で構成されますが、構成は基本的に同じです。

上記自体は投げることができますIndexOutOfRangeExceptionか?

配列アクセス(および例外)が上記の行から呼び出されたコード、つまりコンストラクターまたはプロパティゲッターの1つにある可能性はありますか?正しい場所を特定するにはどうすればよいですか?

問題は開発環境では再現できず、お客様のマシンにVisualStudioをインストールできません。

4

2 に答える 2

2

Can the above itself throw IndexOutOfRangeException?

That line can't in and of itself throw the exception.

Some code inside the XyzConnection constructor method could be doing it, Or, the property getter for anObject.aProperty could be throwing it, or the property getter for aProperty.anotherProperty could also be throwing. My bet would be that it is one of the property getters.

They could be being inlined by the JIT compiler, and hence you wouldn't see them in the stack trace, no matter what PDB's you had. This is actually quite common, as propert getters are usually small and simple, which makes them ideal candidates for inlining.

I'd recommend a solid code review of those 2 property getters, followed by the XyzConnection constructor

于 2012-07-19T00:13:55.197 に答える
0

最初に頭に浮かぶのは、PDB が使用されている DLL のバージョンと一致しないということです。コードの行については、Index Out of Range 例外を示唆するものは何もありません。その呼び出しを囲むコードとコンストラクター宣言自体を見なければ、人々が与えることができる多くの助けがあるとは思えません。

誤解を招く行番号に関してチェックすべきもう 1 つの点は、コードが try/catch ブロックを使用している場合、例外を再発生させている catch ブロックが「throw;」を使用していることを確認することです。「元を投げる」ではありません。(ここで、ex はキャッチされた例外です。) これにより、例外トレース スタックが再生成されます。(両方とも時間がかかり、潜在的に有用な情報を上書きします。)

于 2012-07-18T21:44:53.930 に答える