Well, in simple terms:
You are trying to access an object that isn't created or currently not in memory.
So how to tackle this:
Debug and let the debugger break... It will directly take you to the variable that is broken... Now your task is to simply fix this.. Using the new keyword in the appropriate place.
If it is caused on some database commands because the object isn't present then all you need to do is do a null check and handle it:
if (i == null) {
// Handle this
}
The hardest one .. if the GC collected the object already... This generally occurs if you are trying to find an object using strings... That is, finding it by name of the object then it may happen that the GC might already cleaned it up... This is hard to find and will become quite a problem... A better way to tackle this is do null checks wherever necessary during the development process. This will save you a lot of time.
By finding by name I mean some framework allow you to FIndObjects using strings and the code might look like this: FindObject("ObjectName");