// Set the error code only if there is an error (i.e. nativeError >= 0). Otherwise the code ----s up on deserialization
// as the Exception..ctor() throws on setting HResult to 0. The default for HResult is -2147467259.
private void SetErrorCodeOnError(int nativeError)
{
if (!WebSocketProtocolComponent.Succeeded(nativeError))
{
this.HResult = nativeError;
}
}