System Namespace


.NET Framework Class Library
ArgumentNullException Class

The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class ArgumentNullException _
    Inherits ArgumentException
Visual Basic (Usage)
Dim instance As ArgumentNullException
C#
[SerializableAttribute]
[ComVisibleAttribute(true)]
public class ArgumentNullException : ArgumentException
Visual C++
[SerializableAttribute]
[ComVisibleAttribute(true)]
public ref class ArgumentNullException : public ArgumentException
JScript
public class ArgumentNullException extends ArgumentException
Remarks

ArgumentNullException is thrown when a method is invoked and at least one of the passed arguments is nullNothingnullptra null reference (Nothing in Visual Basic) but should never be nullNothingnullptra null reference (Nothing in Visual Basic).

ArgumentNullException behaves identically to ArgumentException. It is provided so that application code can differentiate between exceptions caused by null arguments and exceptions caused by arguments that are not null. For errors caused by arguments that are not null, see ArgumentOutOfRangeException.

ArgumentNullException uses the HRESULT E_POINTER, which has the value 0x80004003.

For a list of initial property values for an instance of ArgumentNullException, see the ArgumentNullException constructors.

Inheritance Hierarchy

System..::.Object
  System..::.Exception
    System..::.SystemException
      System..::.ArgumentException
        System..::.ArgumentNullException
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
See Also

Reference

Other Resources

Tags :


Community Content

David M. Kean - MSFT
ArgumentNullException Throwing Guidelines

For guidelines on when to throw ArgumentNullException and related exceptions, see:

http://davesbox.com/archive/2008/06/17/argumentexception-throwing-guidelines.aspx

Tags :

Page view tracker