System.Net.Security.NegotiateStreamPal.CreateExceptionFromError C# (CSharp) Method

CreateExceptionFromError() static private method

static private CreateExceptionFromError ( SecurityStatusPal statusCode ) : Win32Exception
statusCode SecurityStatusPal
return System.ComponentModel.Win32Exception
        internal static Win32Exception CreateExceptionFromError(SecurityStatusPal statusCode)
        {
            return new Win32Exception((int)SecurityStatusAdapterPal.GetInteropFromSecurityStatusPal(statusCode));
        }

Usage Example

Example #1
0
        private unsafe byte[] GetOutgoingBlob(byte[] incomingBlob, ref Exception e)
        {
            SecurityStatusPal statusCode;

            byte[] message = _context.GetOutgoingBlob(incomingBlob, false, out statusCode);

            if (IsError(statusCode))
            {
                e = NegotiateStreamPal.CreateExceptionFromError(statusCode);
                uint error = (uint)e.HResult;

                message = new byte[sizeof(long)];
                for (int i = message.Length - 1; i >= 0; --i)
                {
                    message[i] = (byte)(error & 0xFF);
                    error      = (error >> 8);
                }
            }

            if (message != null && message.Length == 0)
            {
                message = s_emptyMessage;
            }

            return(message);
        }