smartcard

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone


Just a quick question! Everytime i run the SCardConnect Command
SCARD_E_INVALID_PARAMETER is returned and i have absolutely no idea why!


I have a VB6 program that works perfectly, but when i try and implement the
same in VB.NET, I get the SCARD_E_INVALID_PARAMETER error.


I was just wondering if anyone could help? when i debug the program
hContext in VB6 = 0 however in VB.NET it = -855572479 or -855572480. Which
then produces a return code of HEX - 80100004 (SCARD_E_INVALID_PARAMETER)


The code i am using is:



Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim defaultReader As String
defaultReader = ComboBox1.Text
Protocol = clsPCSC.GetProtocol


ReturnCode = clsPCSC.winSCard.SCardConnect _
( _
hContext, _
defaultReader, _
clsPCSC.SCARD_SHARE_EXCLUSIVE, _
clsPCSC.SCARD_PROTOCOL_T0, _
hCard, _
Protocol _
)


If ReturnCode <> clsPCSC.SCARD_S_SUCCESS Then
MessageBox.Show( _
"An Error Occurred when connecting to the smarcard" _
& ControlChars.CrLf & "Error Number: " & Hex(ReturnCode), _
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning, _
MessageBoxDefaultButton.Button1,
MessageBoxOptions.DefaultDesktopOnly)
Else
List1.Items.Add("Connection OK")
End If
End Sub


HOPEFULLY someone can help


Thanks in advance,
 
Hi,

Maybe this will help
http://www.aspfree.com/index.php?option=content&task=view&id=2108

Ken
----------------
<Windy> wrote in message Hi everyone


Just a quick question! Everytime i run the SCardConnect Command
SCARD_E_INVALID_PARAMETER is returned and i have absolutely no idea why!


I have a VB6 program that works perfectly, but when i try and implement the
same in VB.NET, I get the SCARD_E_INVALID_PARAMETER error.


I was just wondering if anyone could help? when i debug the program
hContext in VB6 = 0 however in VB.NET it = -855572479 or -855572480. Which
then produces a return code of HEX - 80100004 (SCARD_E_INVALID_PARAMETER)


The code i am using is:



Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim defaultReader As String
defaultReader = ComboBox1.Text
Protocol = clsPCSC.GetProtocol


ReturnCode = clsPCSC.winSCard.SCardConnect _
( _
hContext, _
defaultReader, _
clsPCSC.SCARD_SHARE_EXCLUSIVE, _
clsPCSC.SCARD_PROTOCOL_T0, _
hCard, _
Protocol _
)


If ReturnCode <> clsPCSC.SCARD_S_SUCCESS Then
MessageBox.Show( _
"An Error Occurred when connecting to the smarcard" _
& ControlChars.CrLf & "Error Number: " & Hex(ReturnCode), _
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning, _
MessageBoxDefaultButton.Button1,
MessageBoxOptions.DefaultDesktopOnly)
Else
List1.Items.Add("Connection OK")
End If
End Sub


HOPEFULLY someone can help


Thanks in advance,
 
Thx Ken,

I had also read this article, but i have no idea where is the dll
SCARDLIBlib, "SCardLib 1.0 Type library" located...and how to get it, I had
installed ACS driver, but no hope to find this library.
 
oh I have this dll, but when I add reference in VS .Net , i can't add it
successfully,
the error said: "This is not a valid assembly or COM component. Only
assemblies with extension 'dll' and COM components can be referenced. Please
make sure that the file is accessible, and that it is a valid assembly or
COM component.

I also tried to register the dll. but fail to do so.
 
Back
Top