The C# exception that is thrown when a null reference is passed to a method that does not accept it as a valid argument. An ArgumentNullException exception is thrown at run time in the following two major circumstances:
-
An uninstantiated object is passed to a method. To prevent the error, instantiate the object.
-
An object returned from a method call is then passed as an argument to a second method, but the value of the original returned object is null. To prevent the error, check for a return value that is null and call the second method only if the return value is not null.