System.Net.Http.WinHttpException.GetErrorMessage C# (CSharp) Method

GetErrorMessage() public static method

public static GetErrorMessage ( int error ) : string
error int
return string
        public static string GetErrorMessage(int error)
        {
            // Look up specific error message in WINHTTP.DLL since it is not listed in default system resources
            // and thus can't be found by default .Net interop.
            IntPtr moduleHandle = Interop.Kernel32.GetModuleHandle(Interop.Libraries.WinHttp);
            return Interop.Kernel32.GetMessage(moduleHandle, error);
        }
    }

Usage Example

Esempio n. 1
0
        public static void TraceAsyncError(string message, Interop.WinHttp.WINHTTP_ASYNC_RESULT asyncResult)
        {
            if (!IsTraceEnabled())
            {
                return;
            }

            uint apiIndex = (uint)asyncResult.dwResult.ToInt32();
            uint error    = asyncResult.dwError;

            Debug.WriteLine(
                "{0}: api={1}, error={2}({3}) \"{4}\"",
                message,
                GetNameFromApiIndex(apiIndex),
                GetNameFromError(error),
                error,
                WinHttpException.GetErrorMessage((int)error));
        }