C# 带WCF的Winscard Dll
我的项目结构C# 带WCF的Winscard Dll,c#,winscard,C#,Winscard,我的项目结构 myApp -->WCFSerLibrary -->ClassLib1 -->ClassLib2 // This one uses winscard.dll 我想与连接的智能卡收割机通信 我遵循的四个步骤是 骇人听闻的背景 通过SCardListReaders获取读卡器名称 疤痕连接 带着伤痕阅读 前三个步骤执行成功,但当我尝试执行SCardTransmit时,它返回的响应代码为87 第二,上面提到的场景是当我从WCF服务调用它时。现在我在
myApp
-->WCFSerLibrary
-->ClassLib1
-->ClassLib2 // This one uses winscard.dll
我想与连接的智能卡收割机通信
我遵循的四个步骤是
retCode = ModWinsCard.SCardTransmit(hCard, ref pioSendRequest, ref SendBuff[0], sendLen, ref pioSendRequest, ref RecvBuff[0], ref recvLen);
在莫德温斯卡德的课堂上
[DllImport("winscard.dll"l)]
public static extern Int64 SCardTransmit(UInt64 hCard, ref SCARD_IO_REQUEST pioSendRequest, ref byte SendBuff, int SendBuffLen, ref SCARD_IO_REQUEST pioRecvRequest, ref byte RecvBuff, ref int RecvBuffLen);
87是无效参数。该方法返回一个不长的int。此外,您只传入输入和输出缓冲区中的第一项。卡把手应使用IntPtr
LONG WINAPI SCardTransmit(
_In_ SCARDHANDLE hCard,
_In_ LPCSCARD_IO_REQUEST pioSendPci,
_In_ LPCBYTE pbSendBuffer,
_In_ DWORD cbSendLength,
_Inout_opt_ LPSCARD_IO_REQUEST pioRecvPci,
_Out_ LPBYTE pbRecvBuffer,
_Inout_ LPDWORD pcbRecvLength
);
也许可以试试下面的pinvoke签名
[DllImport("winscard.dll"l)]
public static extern int SCardTransmit(
IntPtr hCard,
ref SCARD_IO_REQUEST pioSendRequest,
byte[] SendBuff,
int SendBuffLen,
ref SCARD_IO_REQUEST pioRecvRequest,
IntPtr RecvBuff, // Copy with marshal.copy to a managed array after call.
ref int RecvBuffLen);
看起来像是线程问题(列表中有87个代码,没有错误)。您能否提供完整的代码,使用智能卡资源管理器?还有,什么是myApp?Windows服务,IIS应用程序?Dennis myApp是一个Windows服务。我引用此链接的位置与long和int相同。我已将其更改为支持64位OSI,但我不确定传递阵列将如何工作。ref byte封送拆收器将只复制单个字节。您是对的,问题在于处理程序已将Int64 hCard更改为UIntPtr hCard(它工作了:)。。再次感谢你:)不,它是64位的-对不起,我需要更改什么吗?