I've run into a very odd bug today. I have a button on a form, clicking it causes a grid on my form to be populated with data. If you click the button twice, it crashes with an 'Object reference not set to an instance of an object.'
I ended up placing a breakpoint at the start of the Sub that handles the population of that grid and I found that...it didn't crash anymore. I'd click the button, press 'F5' in Visual Studio and it wouldn't crash. I did this, at least, 10 times, it was fixed.
Then, I removed the breakpoint, F5'ed, clicked the button and it crashes. Adding the breakpoint back in, allows it to work.
Can someone explain what is going on here? The grid I'm using is a 3rd party control (Infragistics) and the application is a WinForms app. I'm not doing any threading - my only thought is that it's some sort of 'race condition'? But even that doesn't really make sense to me.
EDIT: This is a VB.Net application / Visual Studio 2008