System.Runtime.InteropServices.Marshal.GetHRForLastWin32Error Method

Returns the HRESULT corresponding to the last error incurred by Win32 code executed using System.Runtime.InteropServices.Marshal.

Syntax

[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)]
public static int GetHRForLastWin32Error ()

Returns

The HRESULT corresponding to the last Win32 error code.

Remarks

The target function must have had the setLastError metadata flag set. For example, the SetLastError field of the System.Runtime.InteropServices.DllImportAttribute must be true. The process for setting this flag depends on the source language used: C# and C++ are false by default, but the Declare statement in Visual Basic is true.

Requirements

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