The Labs \ Source Viewer \ SSCLI \ System \ ArgumentNullException

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 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. ** Purpose: Exception class for null arguments to a method.
  21. **
  22. **
  23. =============================================================================*/
  24. namespace System
  25. {
  26.    
  27.     using System;
  28.     using System.Runtime.Serialization;
  29.     using System.Runtime.Remoting;
  30.     using System.Security.Permissions;
  31.    
  32.     // The ArgumentException is thrown when an argument
  33.     // is null when it shouldn't be.
  34.     //
  35.     [System.Runtime.InteropServices.ComVisible(true)]
  36.     [Serializable()]
  37.     public class ArgumentNullException : ArgumentException
  38.     {
  39.         // Creates a new ArgumentNullException with its message
  40.         // string set to a default message explaining an argument was null.
  41.         public ArgumentNullException() : base(Environment.GetResourceString("ArgumentNull_Generic"))
  42.         {
  43.             // Use E_POINTER - COM used that for null pointers. Description is "invalid pointer"
  44.             SetErrorCode(__HResults.E_POINTER);
  45.         }
  46.        
  47.         public ArgumentNullException(string paramName) : base(Environment.GetResourceString("ArgumentNull_Generic"), paramName)
  48.         {
  49.             SetErrorCode(__HResults.E_POINTER);
  50.         }
  51.        
  52.         public ArgumentNullException(string message, Exception innerException) : base(message, innerException)
  53.         {
  54.             SetErrorCode(__HResults.E_POINTER);
  55.         }
  56.        
  57.         public ArgumentNullException(string paramName, string message) : base(message, paramName)
  58.         {
  59.             SetErrorCode(__HResults.E_POINTER);
  60.         }
  61.        
  62.         [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
  63.         protected ArgumentNullException(SerializationInfo info, StreamingContext context) : base(info, context)
  64.         {
  65.         }
  66.     }
  67. }

Developer Fusion