Debugging Puzzler - WinForms crash - Can you figure out what caused it?

1 minute read

Earlier this week I was doing a presentation and since the company I presented for had mostly win forms developers I wanted to convert all my ASP.NET debugging demos to win forms equivalents for the presentation.

As I was converting my first demo (a performance issue) I ran into a bit of a snag because the first time I ran the demo (which populates 4 data grid views with product information) things worked fine. I clicked the Featured Products button, my data grids were nicely filled, I could reproduce my performance issue and debug it.

The second time I clicked the button to reproduce the issue however I was met with this:

WinformsCrash

Instead of data in my data grids they were just covered with big red X:es and the application crashed with a NullReferenceException (Object reference not set to an instance of an object) in System.Windows.Forms.DataGridViewRowHeaderCell.PaintPrivate.

I have uploaded the faulting application here if you want to try reproducing and debugging the issue and figure out what happened, feel free to post your suggestions for causes and resolutions in the comments.

The first comment that leads to a resolution will be dubbed “Master Debugger August 2008” :) I’ll post my answer later on.

Have fun, Tess