NullReferenceException is thrown whenever a variable is empty and one of its method/properties are referenced. To avoid this, be sure all variables are initialized correctly (new operator), and all methods returns a non-null value.
new