The Labs \ Source Viewer \ SSCLI \ System.Runtime.CompilerServices \ RuntimeWrappedException

  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: RuntimeWrappedException
  18. **
  19. **
  20. ** Purpose: The exception class uses to wrap all non-CLS compliant exceptions.
  21. **
  22. **
  23. =============================================================================*/
  24. namespace System.Runtime.CompilerServices
  25. {
  26.     using System;
  27.     using System.Runtime.Serialization;
  28.     using System.Runtime.Remoting;
  29.     using System.Security.Permissions;
  30.    
  31.     [Serializable()]
  32.     public sealed class RuntimeWrappedException : Exception
  33.     {
  34.         private RuntimeWrappedException(object thrownObject) : base(Environment.GetResourceString("RuntimeWrappedException"))
  35.         {
  36.             SetErrorCode(System.__HResults.COR_E_RUNTIMEWRAPPED);
  37.             m_wrappedException = thrownObject;
  38.         }
  39.        
  40.         public object WrappedException {
  41.             get { return m_wrappedException; }
  42.         }
  43.        
  44.         private object m_wrappedException;
  45.        
  46.         [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
  47.         public override void GetObjectData(SerializationInfo info, StreamingContext context)
  48.         {
  49.             if (info == null) {
  50.                 throw new ArgumentNullException("info");
  51.             }
  52.             base.GetObjectData(info, context);
  53.             info.AddValue("WrappedException", m_wrappedException, typeof(object));
  54.         }
  55.        
  56.         internal RuntimeWrappedException(SerializationInfo info, StreamingContext context) : base(info, context)
  57.         {
  58.             m_wrappedException = info.GetValue("WrappedException", typeof(object));
  59.         }
  60.     }
  61. }

Developer Fusion