VB.NET Datatable "Index was out of range."
Posted on 2010-11-19
I have VB.NET App with 2 threads.
Both threads read and update a Datatable.
When the App starts the structure and rows (20c, 100 r) are setup.
The Datatable is basically an object to hold information used by the program, the threads read/change this data while it runs.
Randomly get the error: "Index was out of range. Must be non-negative and less than the size of the collection."
When the code breaks on this error I can confirm using the "Immediate Window" that the reference is valid.
A typical reference is: dtData(10)("Name")
The Datatable schema, # rows, and # cols are not changing and I'm sure the Index is valid, and the ref Col exists.
Is there some other problem with 2 threads accessing the same Datatable??