public SmartCardSharingException(PcscException innerException) : base("A sharing violation occurred.", innerException) { }
internal static Exception ToException(int returnValue) { PcscException ex = new PcscException(returnValue); switch (returnValue) { case 109: return(new NotSupportedException("The local system does not support smart card redirection", ex)); default: { SmartCardErrors value = (SmartCardErrors)returnValue; switch (value) { case SmartCardErrors.InternalError: return(new SystemException("PC/SC internal error", ex)); case SmartCardErrors.Cancelled: return(new OperationCanceledException("Cancelled", ex)); case SmartCardErrors.InvalidHandle: return(new ArgumentException("Invalid handle", ex)); case SmartCardErrors.InvalidParameter: return(new ArgumentException("Invalid parameter", ex)); case SmartCardErrors.InvalidTarget: return(new SystemException("Invalid target", ex)); case SmartCardErrors.NoMemory: return(new OutOfMemoryException("No memory", ex)); case SmartCardErrors.WaitedTooLong: return(new TimeoutException("Waited too long", ex)); case SmartCardErrors.InsufficientBuffer: return(new InternalBufferOverflowException("Insufficient buffer", ex)); case SmartCardErrors.UnknownReader: return(new ArgumentException("Unknown reader", ex)); case SmartCardErrors.Timeout: return(new TimeoutException("Timeout", ex)); case SmartCardErrors.SharingViolation: return(new SmartCardSharingException(ex)); case SmartCardErrors.NoSmartcard: return(new Exception("No smart card", ex)); case SmartCardErrors.UnknownCard: return(new Exception("Unknown card", ex)); case SmartCardErrors.CantDispose: return(new Exception("Can't dispose", ex)); case SmartCardErrors.ProtocolMismatch: return(new IOException("Protocol mismatch", ex)); case SmartCardErrors.NotReady: return(new InvalidOperationException("Not ready", ex)); case SmartCardErrors.InvalidValue: return(new ArgumentException("Invalid value", ex)); case SmartCardErrors.SystemCancelled: return(new Exception("System cancelled", ex)); case SmartCardErrors.CommError: return(new IOException("Comm error", ex)); case SmartCardErrors.UnknownError: return(new Exception("Unknown error", ex)); case SmartCardErrors.InvalidAtr: return(new ArgumentException("Invalid ATR", ex)); case SmartCardErrors.NotTransacted: return(new Exception("Not transacted", ex)); case SmartCardErrors.ReaderUnavailable: return(new Exception("Reader unavailable", ex)); case SmartCardErrors.Shutdown: return(new SystemException("Shutdown", ex)); case SmartCardErrors.PciTooSmall: return(new SystemException("PCI too small", ex)); case SmartCardErrors.ReaderUnsupported: return(new NotSupportedException("Reader unsupported", ex)); case SmartCardErrors.DuplicateReader: return(new ArgumentException("Duplicate reader", ex)); case SmartCardErrors.CardUnsupported: return(new NotSupportedException("Card unsupported", ex)); case SmartCardErrors.NoService: return(new SystemException("No service", ex)); case SmartCardErrors.ServiceStopped: return(new SystemException("Service stopped", ex)); case SmartCardErrors.Unexpected: return(new Exception("Unexpected", ex)); case SmartCardErrors.IccInstallation: return(new Exception("ICC installation", ex)); case SmartCardErrors.IccCreateOrder: return(new Exception("ICC create order", ex)); case SmartCardErrors.UnsupportedFeature: return(new NotSupportedException("Unsupported feature", ex)); case SmartCardErrors.DirNotFound: return(new DirectoryNotFoundException("Directory not found", ex)); case SmartCardErrors.FileNotFound: return(new FileNotFoundException("File not found", ex)); case SmartCardErrors.NoDir: return(new InvalidOperationException("No directory", ex)); case SmartCardErrors.NoFile: return(new InvalidOperationException("No file", ex)); case SmartCardErrors.NoAccess: return(new Exception("No access", ex)); case SmartCardErrors.WriteTooMany: return(new Exception("Write too many", ex)); case SmartCardErrors.BadSeek: return(new Exception("Bad seek", ex)); case SmartCardErrors.InvalidChv: return(new Exception("Invalid CHV", ex)); case SmartCardErrors.UnknownResMng: return(new ArgumentException("Unknown resource manager", ex)); case SmartCardErrors.NoSuchCertificate: return(new Exception("No such certificate", ex)); case SmartCardErrors.CertificateUnavailable: return(new Exception("Certificate unavailable", ex)); case SmartCardErrors.NoReadersAvailable: return(new Exception("No readers available", ex)); case SmartCardErrors.CommDataLost: return(new IOException("Comm data lost", ex)); case SmartCardErrors.NoKeyContainer: return(new Exception("No key container", ex)); case SmartCardErrors.ServerTooBusy: return(new SystemException("Server too busy", ex)); case SmartCardErrors.UnsupportedCard: return(new NotSupportedException("Unsupported card", ex)); case SmartCardErrors.UnresponsiveCard: return(new IOException("UnresponsiveCard", ex)); case SmartCardErrors.UnpoweredCard: return(new IOException("Unpowered card", ex)); case SmartCardErrors.ResetCard: return(new IOException("Reset card", ex)); case SmartCardErrors.RemovedCard: return(new IOException("Removed card", ex)); case SmartCardErrors.SecurityViolation: return(new System.Security.SecurityException("Security violation", ex)); case SmartCardErrors.WrongChv: return(new Exception("Wrong CHV", ex)); case SmartCardErrors.ChvBlocked: return(new Exception("CHV blocked", ex)); case SmartCardErrors.Eof: return(new IOException("EOF", ex)); case SmartCardErrors.CancelledByUser: return(new Exception("Cancelled by user", ex)); case SmartCardErrors.CardNotAuthenticated: return(new Exception("Card not authenticated", ex)); default: return(new Exception("PC/SC error " + value.ToString() + " (" + returnValue.ToString("X") + ")", ex)); } } } }
internal static Exception ToException(int returnValue) { PcscException ex = new PcscException(returnValue); switch (returnValue) { case 109: return new NotSupportedException("The local system does not support smart card redirection", ex); default: { SmartCardErrors value = (SmartCardErrors)returnValue; switch (value) { case SmartCardErrors.InternalError: return new SystemException("PC/SC internal error", ex); case SmartCardErrors.Cancelled: return new OperationCanceledException("Cancelled", ex); case SmartCardErrors.InvalidHandle: return new ArgumentException("Invalid handle", ex); case SmartCardErrors.InvalidParameter: return new ArgumentException("Invalid parameter", ex); case SmartCardErrors.InvalidTarget: return new SystemException("Invalid target", ex); case SmartCardErrors.NoMemory: return new OutOfMemoryException("No memory", ex); case SmartCardErrors.WaitedTooLong: return new TimeoutException("Waited too long", ex); case SmartCardErrors.InsufficientBuffer: return new InternalBufferOverflowException("Insufficient buffer", ex); case SmartCardErrors.UnknownReader: return new ArgumentException("Unknown reader", ex); case SmartCardErrors.Timeout: return new TimeoutException("Timeout", ex); case SmartCardErrors.SharingViolation: return new SmartCardSharingException(ex); case SmartCardErrors.NoSmartcard: return new Exception("No smart card", ex); case SmartCardErrors.UnknownCard: return new Exception("Unknown card", ex); case SmartCardErrors.CantDispose: return new Exception("Can't dispose", ex); case SmartCardErrors.ProtocolMismatch: return new IOException("Protocol mismatch", ex); case SmartCardErrors.NotReady: return new InvalidOperationException("Not ready", ex); case SmartCardErrors.InvalidValue: return new ArgumentException("Invalid value", ex); case SmartCardErrors.SystemCancelled: return new Exception("System cancelled", ex); case SmartCardErrors.CommError: return new IOException("Comm error", ex); case SmartCardErrors.UnknownError: return new Exception("Unknown error", ex); case SmartCardErrors.InvalidAtr: return new ArgumentException("Invalid ATR", ex); case SmartCardErrors.NotTransacted: return new Exception("Not transacted", ex); case SmartCardErrors.ReaderUnavailable: return new Exception("Reader unavailable", ex); case SmartCardErrors.Shutdown: return new SystemException("Shutdown", ex); case SmartCardErrors.PciTooSmall: return new SystemException("PCI too small", ex); case SmartCardErrors.ReaderUnsupported: return new NotSupportedException("Reader unsupported", ex); case SmartCardErrors.DuplicateReader: return new ArgumentException("Duplicate reader", ex); case SmartCardErrors.CardUnsupported: return new NotSupportedException("Card unsupported", ex); case SmartCardErrors.NoService: return new SystemException("No service", ex); case SmartCardErrors.ServiceStopped: return new SystemException("Service stopped", ex); case SmartCardErrors.Unexpected: return new Exception("Unexpected", ex); case SmartCardErrors.IccInstallation: return new Exception("ICC installation", ex); case SmartCardErrors.IccCreateOrder: return new Exception("ICC create order", ex); case SmartCardErrors.UnsupportedFeature: return new NotSupportedException("Unsupported feature", ex); case SmartCardErrors.DirNotFound: return new DirectoryNotFoundException("Directory not found", ex); case SmartCardErrors.FileNotFound: return new FileNotFoundException("File not found", ex); case SmartCardErrors.NoDir: return new InvalidOperationException("No directory", ex); case SmartCardErrors.NoFile: return new InvalidOperationException("No file", ex); case SmartCardErrors.NoAccess: return new Exception("No access", ex); case SmartCardErrors.WriteTooMany: return new Exception("Write too many", ex); case SmartCardErrors.BadSeek: return new Exception("Bad seek", ex); case SmartCardErrors.InvalidChv: return new Exception("Invalid CHV", ex); case SmartCardErrors.UnknownResMng: return new ArgumentException("Unknown resource manager", ex); case SmartCardErrors.NoSuchCertificate: return new Exception("No such certificate", ex); case SmartCardErrors.CertificateUnavailable: return new Exception("Certificate unavailable", ex); case SmartCardErrors.NoReadersAvailable: return new Exception("No readers available", ex); case SmartCardErrors.CommDataLost: return new IOException("Comm data lost", ex); case SmartCardErrors.NoKeyContainer: return new Exception("No key container", ex); case SmartCardErrors.ServerTooBusy: return new SystemException("Server too busy", ex); case SmartCardErrors.UnsupportedCard: return new NotSupportedException("Unsupported card", ex); case SmartCardErrors.UnresponsiveCard: return new IOException("UnresponsiveCard", ex); case SmartCardErrors.UnpoweredCard: return new IOException("Unpowered card", ex); case SmartCardErrors.ResetCard: return new IOException("Reset card", ex); case SmartCardErrors.RemovedCard: return new IOException("Removed card", ex); case SmartCardErrors.SecurityViolation: return new System.Security.SecurityException("Security violation", ex); case SmartCardErrors.WrongChv: return new Exception("Wrong CHV", ex); case SmartCardErrors.ChvBlocked: return new Exception("CHV blocked", ex); case SmartCardErrors.Eof: return new IOException("EOF", ex); case SmartCardErrors.CancelledByUser: return new Exception("Cancelled by user", ex); case SmartCardErrors.CardNotAuthenticated: return new Exception("Card not authenticated", ex); default: return new Exception("PC/SC error " + value.ToString() + " (" + returnValue.ToString("X") + ")", ex); } } } }