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: SystemAssembly: mscorlib.dll
1: // ==++== 2: // 3: // 4: // Copyright (c) 2002 Microsoft Corporation. All rights reserved. 5: // 6: // The use and distribution terms for this software are contained in the file 7: // named license.txt, which can be found in the root of this distribution. 8: // By using this software in any fashion, you are agreeing to be bound by the 9: // terms of this license. 10: // 11: // You must not remove this notice, or any other, from this software. 12: // 13: // 14: // ==--== 15: /*============================================================================= 16: ** 17: ** Class: ArgumentNullException 18: ** 19: ** 20: ** 21: ** Purpose: Exception class for null arguments to a method. 22: ** 23: ** Date: April 28, 1999 24: ** 25: =============================================================================*/ 26: 27: namespace System { 28: _nullMessage - Info | MSDN | Search 29: using System; 30: using System.Runtime.Serialization; 31: using System.Runtime.Remoting; 32: // The ArgumentException is thrown when an argument 33: // is null when it shouldn't be. 34: // 35: /// <include file='doc\ArgumentNullException.uex' path='docs/doc[@for="ArgumentNullException"]/*' /> 36: [Serializable] public class ArgumentNullException : ArgumentException 37: { 38: private static String _nullMessage = null; 39: 40: private static String NullMessage { 41: get { 42: // Don't bother with synchronization here. A duplicated string 43: // is not a major problem. 44: if (_nullMessage == null) 45: _nullMessage = Environment.GetResourceString("ArgumentNull_Generic"); 46: return _nullMessage; 47: } 48: } 49: 50: // Creates a new ArgumentNullException with its message 51: // string set to a default message explaining an argument was null. 52: /// <include file='doc\ArgumentNullException.uex' path='docs/doc[@for="ArgumentNullException.ArgumentNullException"]/*' /> 53: public ArgumentNullException() 54: : base(NullMessage) { 55: // Use E_POINTER - COM used that for null pointers. Description is "invalid pointer" 56: SetErrorCode(__HResults.E_POINTER); 57: } 58: 59: /// <include file='doc\ArgumentNullException.uex' path='docs/doc[@for="ArgumentNullException.ArgumentNullException1"]/*' /> 60: public ArgumentNullException(String paramName) 61: : base(NullMessage, paramName) { 62: SetErrorCode(__HResults.E_POINTER); 63: } 64: 65: /// <include file='doc\ArgumentNullException.uex' path='docs/doc[@for="ArgumentNullException.ArgumentNullException2"]/*' /> 66: public ArgumentNullException(String paramName, String message) 67: : base(message, paramName) { 68: SetErrorCode(__HResults.E_POINTER); 69: 70: } 71: 72: /// <include file='doc\ArgumentNullException.uex' path='docs/doc[@for="ArgumentNullException.ArgumentNullException3"]/*' /> 73: protected ArgumentNullException(SerializationInfo info, StreamingContext context) : base(info, context) { 74: } 75: } 76: } Generated on 24/10/2003 19:00:30