本文整理汇总了C#中SCardError类的典型用法代码示例。如果您正苦于以下问题:C# SCardError类的具体用法?C# SCardError怎么用?C# SCardError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SCardError类属于命名空间,在下文中一共展示了SCardError类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: connect
public static void connect()
{
hContext = new SCardContext();
hContext.Establish(SCardScope.System);
string[] readerList = hContext.GetReaders();
Boolean noReaders = readerList.Length <= 0;
if (noReaders)
{
throw new PCSCException(SCardError.NoReadersAvailable, "Blad czytnika");
}
Console.WriteLine("Nazwa czytnika: " + readerList[0]);
reader = new SCardReader(hContext);
err = reader.Connect(readerList[0],
SCardShareMode.Shared,
SCardProtocol.T0 | SCardProtocol.T1);
checkError(err);
switch (reader.ActiveProtocol)
{
case SCardProtocol.T0:
protocol = SCardPCI.T0;
break;
case SCardProtocol.T1:
protocol = SCardPCI.T1;
break;
default:
throw new PCSCException(SCardError.ProtocolMismatch, "nieobslugiwany protokol: "+ reader.ActiveProtocol.ToString());
}
}
示例2: ThrowExceptionOnSCardError
/// <summary>
/// Throws an exception if <paramref name="sc"/> is not <see cref="F:PCSC.SCardError.Success"/>.
/// </summary>
/// <param name="sc">The error code returned from the native PC/SC library.</param>
protected void ThrowExceptionOnSCardError(SCardError sc)
{
if (sc == SCardError.Success)
return; // No Error
// An error occurred during connect attempt.
if (sc == SCardError.InvalidHandle)
throw new InvalidContextException(sc);
if (sc == SCardError.InvalidParameter)
throw new InvalidProtocolException(sc);
if (sc == SCardError.InvalidParameter)
throw new InvalidParameterException(sc);
if (sc == SCardError.InvalidValue)
throw new InvalidValueException(sc);
if (sc == SCardError.NoService)
throw new NoServiceException(sc);
if (sc == SCardError.NoSmartcard)
throw new NoSmartcardException(sc);
if (sc == SCardError.NotReady)
throw new NotReadyException(sc);
if (sc == SCardError.ReaderUnavailable)
throw new ReaderUnavailableException(sc);
if (sc == SCardError.SharingViolation)
throw new SharingViolationException(sc);
if (sc == SCardError.UnknownReader)
throw new UnknownReaderException(sc);
if (sc == SCardError.UnsupportedCard)
throw new UnsupportedFeatureException(sc);
if (sc == SCardError.CommunicationError)
throw new CommunicationErrorException(sc);
if (sc == SCardError.InternalError)
throw new InternalErrorException(sc);
if (sc == SCardError.UnpoweredCard)
throw new UnpoweredCardException(sc);
if (sc == SCardError.UnresponsiveCard)
throw new UnresponsiveCardException(sc);
if (sc == SCardError.RemovedCard)
throw new RemovedCardException(sc);
if (sc == SCardError.InsufficientBuffer)
throw new InsufficientBufferException(sc);
// unexpected error
throw new PCSCException(sc);
}
示例3: UnresponsiveCardException
/// <summary>
/// Initializes a new instance of the <see cref="UnresponsiveCardException"/> class.
/// </summary>
/// <param name="serr">System's error code</param>
/// <param name="message">An error message text.</param>
public UnresponsiveCardException(SCardError serr, string message)
: base(serr, message)
{
}
示例4: InvalidValueException
/// <summary>
/// Initializes a new instance of the <see cref="InvalidValueException"/> class.
/// </summary>
/// <param name="serr">System's error code</param>
/// <param name="message">An error message text.</param>
/// <param name="innerException">The inner exception.</param>
public InvalidValueException(SCardError serr, string message, Exception innerException)
: base(serr, message, innerException)
{
}
示例5: InvalidShareModeException
public InvalidShareModeException(SCardError serr)
: base(serr)
{
}
示例6: InsufficientBufferException
public InsufficientBufferException(SCardError serr)
: base(serr) { }
示例7: NoServiceException
public NoServiceException(SCardError serr, string message)
: base(serr, message)
{
}
示例8: SharingViolationException
public SharingViolationException(SCardError serr, string message)
: base(serr, message)
{
}
示例9: InvalidParameterException
/// <summary>
/// Creates a new instance.
/// </summary>
/// <param name="serr">System's error code</param>
/// <param name="message">Error message</param>
public InvalidParameterException(SCardError serr, string message)
: base(serr, message) {}
示例10: RemovedCardException
/// <summary>
/// Initializes a new instance of the <see cref="RemovedCardException"/> class.
/// </summary>
/// <param name="serr">System's error code</param>
/// <param name="message">An error message text.</param>
/// <param name="innerException">The inner exception.</param>
public RemovedCardException(SCardError serr, string message, Exception innerException)
: base(serr, message, innerException)
{
}
示例11: UnsupportedFeatureException
/// <summary>
/// Initializes a new instance of the <see cref="UnsupportedFeatureException"/> class.
/// </summary>
/// <param name="serr">System's error code</param>
/// <param name="message">An error message text.</param>
/// <param name="innerException">The inner exception.</param>
public UnsupportedFeatureException(SCardError serr, string message, Exception innerException)
: base(serr, message, innerException)
{
}
示例12: PCSCException
/// <summary>
/// Creates a new instance.
/// </summary>
/// <param name="serr">System's error code</param>
public PCSCException(SCardError serr)
: base(SCardHelper.StringifyError(serr)) {
SCardError = serr;
}
示例13: sendCommand
public static void sendCommand(byte[] comand, String name)
{
byte[] recivedBytes = new byte[256];
err = reader.Transmit(protocol, comand, ref recivedBytes);
checkError(err);
writeResponse(recivedBytes, name);
}