Exception thrown: 'System.IndexOutOfRangeException' in System.Data.dll
This is what I'm getting as output when debugging my WPF application. More than once, but nothing else.
No line numbers, no stacktrace, nor anything else to tell me where this is occurring in my code -- Based on how many of these I get and when they occur, I strongly suspect it is happening inside of an (every 10 second) TimedEvent in call(s) to reader.getOrdinal(fieldName)
gone awry.
I'd love to prove/disprove that though.
The application doesn't die there, so this gives me the impression that this is happening inside of a try/catch/finally block...but none of my catch blocks output a message like this. If it were in one of my catch blocks, I'd also expect other output as well, which I don't get. I suppose it could be unrelated to any of my code (hence no stacktrace showing a call back to it), and I just happen to be getting a ringside seat to see something going wrong inside of CLR.
If it matters, these calls are attempts to read data out of ancient MSAccess database. I'd post the code if I thought it would be of any help.
I'm an experienced programmer albeit WPF is not my primary expertise, and I've not encountered an exception that gives such useless debugging information like this. My goal here is to understand what it means when this happens and what I can do about nailing down where.
EDIT:
Found it is happening in a try block. WHY does it generate a message for a caught exception?!?
Code follows.
if (t != null && t.CurrentBoard != 0) // If Game isn't Over
{
int cb = t.CurrentBoard;
int cr = t.CurrentRound;
try
{
THIS CALL RIGHT HERE
col = reader.GetOrdinal(cb.ToString()); // exception if current board score doesn't exist
}
catch (IndexOutOfRangeException)
{
col = -1;
}
if (col != -1 && !reader.IsDBNull(col) && reader.GetValue(col) != DBNull.Value)
{
// If a score for the current board has been submitted