我正在尝试在我的WCF项目中使用winscard.dll的连接功能连接到智能卡。 Wcf服务,使用远程机器发布,该机器安装在Windows Server 8.1
上ScardConnect函数返回值为6。
public int Connect()
{
int returnCode = -2;
string[] tempStr = new string[3];
returnCode = ModWinsCard.SCardEstablishContext(ModWinsCard.SCARD_SCOPE_USER,
0, 0, ref hContext);
if (returnCode == ModWinsCard.SCARD_S_SUCCESS)
{
returnCode = ModWinsCard.SCardConnect(hContext, "ACS ACR1281 1S Dual Reader PICC 0", ModWinsCard.SCARD_SHARE_SHARED, ModWinsCard.SCARD_PROTOCOL_T0 | ModWinsCard.SCARD_PROTOCOL_T1, ref hCard, ref pdwActiveProtocol);
if (returnCode == ModWinsCard.SCARD_S_SUCCESS)
return 1;
else
return returnCode;
}
else
return returnCode;
}
Interface (IService1)
[OperationContract的] [FaultContract(typeof运算(服务1))] int Connect(int hContext,string szReaderName,ref int phCard,ref int ActiveProtocol);
ScardConnect功能
[DllImport("winscard.dll")]
public static extern int SCardConnect(int hContext, string szReaderName, int dwShareMode, int dwPrefProtocol, ref int phCard, ref int ActiveProtocol);
返回代码' 6'是什么意思。
注意:Wcf项目构建操作:x86 客户端项目构建操作:x86