0 comments

I stumbled across an interesting phenomenon yesterday while working a bit on a small utility to help me update the model galleries on www.fotograffen.dk. The basic idea behind the app is to allow me to simply select a number of images, type in a model name and a shooting date and click a button. The program then creates a zip file containing thumbnails, fullsize images and an XML file containing a bit of information about what to do with which files. On the server end, I have a file upload mechanism that unpacks the zip file and adds the model (or gallery) to the page. All in all very clever (or so I think).

Anyway, what happened was this. I had decided to use a ListView to show me the images to choose from. I set the ChecBoxes property to true on the ListView and went ahead and coded what I thought was what was needed. I have a Label on my Form that shows how many pictures have been selected. The first thing that happened when I tried to run the application was that it threw a NullReferenceException

The thing that struck me the most was that it was the Count property that was throwing the exception. I never really found a way out of this other than to wrap a try...catch around the call and output a "0" if an exception was thrown and the Count property at other times.

I think this looks like a bug in the .NET framework (2.0) - I mean... when an object exists, all its properties SHOULD return something meaningful, right? Comments anyone?

comments powered by Disqus