mscorlib(4.0.0.0) API with additions
COMException.cs
1 using Microsoft.Win32;
4 using System.Security;
5 
7 {
10  [ComVisible(true)]
11  [__DynamicallyInvokable]
13  {
15  [__DynamicallyInvokable]
16  public COMException()
17  : base(Environment.GetResourceString("Arg_COMException"))
18  {
19  SetErrorCode(-2147467259);
20  }
21 
24  [__DynamicallyInvokable]
25  public COMException(string message)
26  : base(message)
27  {
28  SetErrorCode(-2147467259);
29  }
30 
34  [__DynamicallyInvokable]
35  public COMException(string message, Exception inner)
36  : base(message, inner)
37  {
38  SetErrorCode(-2147467259);
39  }
40 
44  [__DynamicallyInvokable]
45  public COMException(string message, int errorCode)
46  : base(message)
47  {
48  SetErrorCode(errorCode);
49  }
50 
51  [SecuritySafeCritical]
52  internal COMException(int hresult)
53  : base(Win32Native.GetMessage(hresult))
54  {
55  SetErrorCode(hresult);
56  }
57 
58  internal COMException(string message, int hresult, Exception inner)
59  : base(message, inner)
60  {
61  SetErrorCode(hresult);
62  }
63 
70  : base(info, context)
71  {
72  }
73 
76  public override string ToString()
77  {
78  string message = Message;
79  string str = GetType().ToString();
80  string text = str + " (0x" + base.HResult.ToString("X8", CultureInfo.InvariantCulture) + ")";
81  if (message != null && message.Length > 0)
82  {
83  text = text + ": " + message;
84  }
85  Exception innerException = base.InnerException;
86  if (innerException != null)
87  {
88  text = text + " ---> " + innerException.ToString();
89  }
90  if (StackTrace != null)
91  {
92  text = text + Environment.NewLine + StackTrace;
93  }
94  return text;
95  }
96  }
97 }
override string ToString()
Creates and returns a string representation of the current exception.
Definition: Exception.cs:474
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
Definition: CultureInfo.cs:263
static string NewLine
Gets the newline string defined for this environment.
Definition: Environment.cs:449
COMException(string message)
Initializes a new instance of the T:System.Runtime.InteropServices.COMException class with a specifie...
Definition: COMException.cs:25
COMException(string message, Exception inner)
Initializes a new instance of the T:System.Runtime.InteropServices.COMException class with a specifie...
Definition: COMException.cs:35
override string ToString()
Converts the contents of the exception to a string.
Definition: COMException.cs:76
Definition: __Canon.cs:3
COMException()
Initializes a new instance of the T:System.Runtime.InteropServices.COMException class with default va...
Definition: COMException.cs:16
new Type GetType()
Gets the runtime type of the current instance.
Definition: Exception.cs:753
override string ToString()
Returns a String representing the name of the current Type.
Definition: Type.cs:2788
The exception that is thrown when an unrecognized HRESULT is returned from a COM method call.
Definition: COMException.cs:12
Describes the source and destination of a given serialized stream, and provides an additional caller-...
COMException(string message, int errorCode)
Initializes a new instance of the T:System.Runtime.InteropServices.COMException class with a specifie...
Definition: COMException.cs:45
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
COMException(SerializationInfo info, StreamingContext context)
Initializes a new instance of the T:System.Runtime.InteropServices.COMException class from serializat...
Definition: COMException.cs:69
virtual string StackTrace
Gets a string representation of the immediate frames on the call stack.
Definition: Exception.cs:162
Exception InnerException
Gets the T:System.Exception instance that caused the current exception.
Definition: Exception.cs:139
virtual string Message
Gets a message that describes the current exception.
Definition: Exception.cs:95
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
The base exception type for all COM interop exceptions and structured exception handling (SEH) except...
Represents errors that occur during application execution.To browse the .NET Framework source code fo...
Definition: Exception.cs:22
Specifies that the class can be serialized.
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16