InsufficientMemoryException.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using System;
  5. using System.Runtime.Serialization;
  6. namespace System
  7. {
  8. /// <summary>
  9. /// Purpose: The exception class for running out of memory
  10. /// but most likely in a non-fatal way that shouldn't
  11. /// be affected by escalation policy. Use this for cases
  12. /// like MemoryFailPoint or a TryAllocate method, where you
  13. /// expect OOM's with no shared state corruption and you
  14. /// want to recover from these errors.
  15. /// </summary>
  16. [Serializable]
  17. [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
  18. public sealed class InsufficientMemoryException : OutOfMemoryException
  19. {
  20. public InsufficientMemoryException() : base(
  21. #if CORECLR
  22. GetMessageFromNativeResources(ExceptionMessageKind.OutOfMemory)
  23. #else
  24. SR.Arg_OutOfMemoryException
  25. #endif
  26. )
  27. {
  28. HResult = HResults.COR_E_INSUFFICIENTMEMORY;
  29. }
  30. public InsufficientMemoryException(string message)
  31. : base(message)
  32. {
  33. HResult = HResults.COR_E_INSUFFICIENTMEMORY;
  34. }
  35. public InsufficientMemoryException(string message, Exception innerException)
  36. : base(message, innerException)
  37. {
  38. HResult = HResults.COR_E_INSUFFICIENTMEMORY;
  39. }
  40. private InsufficientMemoryException(SerializationInfo info, StreamingContext context) : base(info, context)
  41. {
  42. }
  43. }
  44. }