The best way to debug this would be to set a breakpoint at the start of retrieving, run in debug mode, and step through the code until you find the statement causing the null object reference. You may just have an uninitialized variable somewhere. This video should help you with the process, if you haven't already gone through the developer video series.
Hope that helps,
Jamie