MissingMethodException.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. **
  7. **
  8. ** Purpose: The exception class for class loading failures.
  9. **
  10. **
  11. =============================================================================*/
  12. using System.Runtime.Serialization;
  13. namespace System
  14. {
  15. [Serializable]
  16. [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
  17. public class MissingMethodException : MissingMemberException
  18. {
  19. public MissingMethodException()
  20. : base(SR.Arg_MissingMethodException)
  21. {
  22. HResult = HResults.COR_E_MISSINGMETHOD;
  23. }
  24. public MissingMethodException(string? message)
  25. : base(message)
  26. {
  27. HResult = HResults.COR_E_MISSINGMETHOD;
  28. }
  29. public MissingMethodException(string? message, Exception? inner)
  30. : base(message, inner)
  31. {
  32. HResult = HResults.COR_E_MISSINGMETHOD;
  33. }
  34. public MissingMethodException(string? className, string? methodName)
  35. {
  36. ClassName = className;
  37. MemberName = methodName;
  38. }
  39. protected MissingMethodException(SerializationInfo info, StreamingContext context)
  40. : base(info, context)
  41. {
  42. }
  43. public override string Message =>
  44. ClassName == null ?
  45. base.Message :
  46. SR.Format(SR.MissingMethod_Name, ClassName + "." + MemberName +
  47. (Signature != null ? " " + FormatSignature(Signature) : string.Empty));
  48. }
  49. }