I believe the first thing you need to look at is changing a setting in Visual Studio. I had a number of issues with this and had to go in an manually tell Visual Studio to break on that NullReferenceException. Once you make this adjustment the IDE will actually throw the error and you can debug your code. From the VS 2008 help:
To break execution when an exception is thrown On the Debug menu, click Exceptions.
In the Exceptions dialog box, select Thrown for an entire category of exceptions, for example, Common Language Runtime Exceptions.
-or-
Expand the node for a category of exceptions, for example, Common Language Runtime Exceptions, and select Thrown for a specific exception within that category.
Steve Massing
2008-11-12 05:14:28