System.Exception.HResult Property

Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

Syntax

public int HResult { get; protected set; }

Value

Documentation for this section has not yet been entered.

Remarks

HRESULT is a 32-bit value, divided into three different fields: a severity code, a facility code, and an error code. The severity code indicates whether the return value represents information, warning, or error. The facility code identifies the area of the system responsible for the error. The error code is a unique number that is assigned to represent the exception. Each exception is mapped to a distinct HRESULT. When managed code throws an exception, the runtime passes the HRESULT to the COM client. When unmanaged code returns an error, the HRESULT is converted to an exception, which is then thrown by the runtime. For information about HRESULT values and their corresponding .NET Framework exceptions, see How to: Map HRESULTs and Exceptions.

Starting with the net_v45, the Exception.HResult property's setter is protected, whereas its getter is public. In previous versions of the .NET Framework, both getter and setter are protected.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0