The Labs \ Source Viewer \ SSCLI \ System \ MissingMemberException

  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: MissingMemberException
  18. **
  19. **
  20. ** Purpose: The exception class for versioning problems with DLLS.
  21. **
  22. **
  23. =============================================================================*/
  24. namespace System
  25. {
  26.    
  27.     using System;
  28.     using System.Runtime.Remoting;
  29.     using System.Runtime.Serialization;
  30.     using System.Runtime.CompilerServices;
  31.     using System.Globalization;
  32.     using System.Security.Permissions;
  33.    
  34.     [System.Runtime.InteropServices.ComVisible(true)]
  35.     [Serializable()]
  36.     public class MissingMemberException : MemberAccessException, ISerializable
  37.     {
  38.         public MissingMemberException() : base(Environment.GetResourceString("Arg_MissingMemberException"))
  39.         {
  40.             SetErrorCode(__HResults.COR_E_MISSINGMEMBER);
  41.         }
  42.        
  43.         public MissingMemberException(string message) : base(message)
  44.         {
  45.             SetErrorCode(__HResults.COR_E_MISSINGMEMBER);
  46.         }
  47.        
  48.         public MissingMemberException(string message, Exception inner) : base(message, inner)
  49.         {
  50.             SetErrorCode(__HResults.COR_E_MISSINGMEMBER);
  51.         }
  52.        
  53.         protected MissingMemberException(SerializationInfo info, StreamingContext context) : base(info, context)
  54.         {
  55.             ClassName = (string)info.GetString("MMClassName");
  56.             MemberName = (string)info.GetString("MMMemberName");
  57.             Signature = (byte[])info.GetValue("MMSignature", typeof(byte[]));
  58.         }
  59.        
  60.         public override string Message {
  61.             get {
  62.                 if (ClassName == null) {
  63.                     return base.Message;
  64.                 }
  65.                 else {
  66.                     // do any desired fixups to classname here.
  67.                     return String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("MissingMember_Name", ClassName + "." + MemberName + (Signature != null ? " " + FormatSignature(Signature) : "")));
  68.                 }
  69.             }
  70.         }
  71.        
  72.         // Called to format signature
  73.         [MethodImplAttribute(MethodImplOptions.InternalCall)]
  74.         static internal extern string FormatSignature(byte[] signature);
  75.        
  76.        
  77.        
  78.         // Potentially called from the EE
  79.         private MissingMemberException(string className, string memberName, byte[] signature)
  80.         {
  81.             ClassName = className;
  82.             MemberName = memberName;
  83.             Signature = signature;
  84.         }
  85.        
  86.         public MissingMemberException(string className, string memberName)
  87.         {
  88.             ClassName = className;
  89.             MemberName = memberName;
  90.         }
  91.        
  92.         [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
  93.         public override void GetObjectData(SerializationInfo info, StreamingContext context)
  94.         {
  95.             if (info == null) {
  96.                 throw new ArgumentNullException("info");
  97.             }
  98.             base.GetObjectData(info, context);
  99.             info.AddValue("MMClassName", ClassName, typeof(string));
  100.             info.AddValue("MMMemberName", MemberName, typeof(string));
  101.             info.AddValue("MMSignature", Signature, typeof(byte[]));
  102.         }
  103.        
  104.        
  105.         // If ClassName != null, GetMessage will construct on the fly using it
  106.         // and the other variables. This allows customization of the
  107.         // format depending on the language environment.
  108.         protected string ClassName;
  109.         protected string MemberName;
  110.         protected byte[] Signature;
  111.     }
  112. }

Developer Fusion