InvalidCastException.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. /*=============================================================================
  5. **
  6. ** Purpose: Exception class for invalid cast conditions!
  7. **
  8. =============================================================================*/
  9. using System.Runtime.Serialization;
  10. namespace System
  11. {
  12. [Serializable]
  13. [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
  14. public class InvalidCastException : SystemException
  15. {
  16. public InvalidCastException()
  17. : base(SR.Arg_InvalidCastException)
  18. {
  19. HResult = HResults.COR_E_INVALIDCAST;
  20. }
  21. public InvalidCastException(string message)
  22. : base(message)
  23. {
  24. HResult = HResults.COR_E_INVALIDCAST;
  25. }
  26. public InvalidCastException(string message, Exception innerException)
  27. : base(message, innerException)
  28. {
  29. HResult = HResults.COR_E_INVALIDCAST;
  30. }
  31. public InvalidCastException(string message, int errorCode)
  32. : base(message)
  33. {
  34. HResult = errorCode;
  35. }
  36. protected InvalidCastException(SerializationInfo info, StreamingContext context) : base(info, context)
  37. {
  38. }
  39. }
  40. }