So I came across this fun error today, which stopped me from being productive for about 2 hours. Unfortunately my search on the internets did not prove to be useful, so I had to manually dig through every part of my code to understand what was going wrong. Seriously, could the error be less generic?
The stack trace indicated that the error was coming from the ListView databinding—which was of some help ,but not much, since the page I was getting the error on has about 10 listviews (It’s a portal type page.)
I tried working out what was recently changed and the biggest thing is that I was now pulling records from a custom DataObjectMethod that pulled data from a cached custom object that I built on request. When I switched my ObjectDataSource back to the original method, the problem went away. So this lead me closer to figuring out what was going on.
So the object that the ObjectDataSource was pulling from was a custom composite object, that held Lists of several types of other business objects. Turns out what was happening is that not all of the objects were being initialized, since some are dependent on gender. So the ListView that was throwing the exception over and over was the one dependent on the gender of the person currently selected.
I added a null check and initialized it if it was null, and now the error went away. Success!
| posted on Sunday, August 16, 2009 12:22 PM