views:

158

answers:

1

According to the documentation for IDataRecord, the implementing methods must throw IndexOutOfRangeException if the field index is out of the range of fields. However, if you try to throw an IndexOutOfRangeException directly in code, FXCop complains that it is a reserved exception type. How do you keep to the IDataRecord exception contract while still keeping FXCop happy?

+3  A: 

Ignore FXCop in the case.

It's perfectly reasonable to throw IndexOutOfRangeException when it's the most appropriate exception to throw - e.g. if you're implementing IList<T>.

You might want to remove it from your FXCop configuration...

Jon Skeet