DataView.get_Item throws a NullReferenceException

  • Thread starter Thread starter Jonathan Allen
  • Start date Start date
J

Jonathan Allen

What could cause a stack trace like this?

Message:Object reference not set to an instance of an object.
Stack Trace:

at System.Data.DataView.GetRecord(Int32 recordIndex)
at System.Data.DataView.get_RowViewCache()
at System.Data.DataView.GetElement(Int32 index)
at System.Data.DataView.get_Item(Int32 recordIndex)
at myCode.myMethod
 
What could cause a stack trace like this?Impossible to tell without more information. Perhaps you could post the
relevant part of myCode.myMethod ?

Greetings,
Wessel
 
Well, at one level it's an ADO.NET bug - the DataView indexer should return
either a valid DataRowView, or throw an IndexOutOfRangeException. Instead
it's crashed somwhere in setting up the DataView's row cache.

The question is, what have you done to upset it so?

Is the problem reproducible - can you you trap the exception in the
debugger?

Did the failure occur on first use for the view, or later?

How was the DataView and underlying table configured? Was anything
interesting changed (like filters, schema, ...) after initially loading the
table?
 
The question is, what have you done to upset it so?

I have no idea. I was hoping to start with a list of "What could have caused
this?", and then work backwards. It is one of those server error log things
that are difficult to track down without knowing the cause. And the code is
way too complex to know where to start.
Is the problem reproducible - can you you trap the exception in the
debugger?

Nope. It is happening (rarely) on our server farm. I think I am just going
to have to right this one off as a mystery.
 
Back
Top