MissingFieldException.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.Runtime.Serialization;
  5. namespace System
  6. {
  7. [Serializable]
  8. [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
  9. public class MissingFieldException : MissingMemberException, ISerializable
  10. {
  11. public MissingFieldException()
  12. : base(SR.Arg_MissingFieldException)
  13. {
  14. HResult = HResults.COR_E_MISSINGFIELD;
  15. }
  16. public MissingFieldException(string message)
  17. : base(message)
  18. {
  19. HResult = HResults.COR_E_MISSINGFIELD;
  20. }
  21. public MissingFieldException(string message, Exception inner)
  22. : base(message, inner)
  23. {
  24. HResult = HResults.COR_E_MISSINGFIELD;
  25. }
  26. public MissingFieldException(string className, string fieldName)
  27. {
  28. ClassName = className;
  29. MemberName = fieldName;
  30. }
  31. protected MissingFieldException(SerializationInfo info, StreamingContext context)
  32. : base(info, context)
  33. {
  34. }
  35. public override string Message
  36. {
  37. get
  38. {
  39. if (ClassName == null)
  40. {
  41. return base.Message;
  42. }
  43. else
  44. {
  45. // do any desired fixups to classname here.
  46. return SR.Format(SR.MissingField_Name, (Signature != null ? FormatSignature(Signature) + " " : "") + ClassName + "." + MemberName);
  47. }
  48. }
  49. }
  50. }
  51. }