NullReferenceException can happen when you call a method on a null variable. For example:
string s = null;
if (s.equals(...))
...
In the example, you have called
equals
method in a
string
variable, but the variable actually doesn't point to any object. It's
null
.
As SAKryukov has wrote in his comment, just debug it, go step by step, and find out which variable is set to null.
See the stack-trace to identify the point which the exception is thrown. Then you will have to check just few lines around that point.