2021-12-14 04:02 AM
Hi eveyone,
I need to use the CR95HF.dll library on a VB.NET application but when i try insert on the project i get an error.
I think this library is VB compatible only but i dont sure about this.
Maybe anyone know how to port this library to be used on VB.NET or how could i use on NET platform.
Thanks.
Regards,
Solved! Go to Solution.
2021-12-16 05:34 AM
Hi,
another suggestion :
Using Visual Studio 2015, the format of DLL answer need to be formatted before to be used :
You must use this formatted variable in all functions to get DLL answer .
another suggestion : it is possible that Get DLL revision doesn't return "0" when you get DLL revision number.
You can can see the exact value with debug mode.
Hope this will help you,
Best regards,
NFC Customer support
2021-12-14 05:44 AM
Hi,
you will find the documentation of the DLL in AN3954. Can you describe the error you have ?
Rgds
BT
2021-12-14 05:50 AM
I am curently using VB.Net 2019 and i need to know how can i add the dll correctly.
If i use the solution of this topic: https://community.st.com/s/question/0D53W000006Oq6qSAC/error-while-loading-cr95hfdll-file
I get an error "System.BadImageFormatException:"
I dont know if this library is compatible with vb.net 2019 version.
Any sugestion?
Thanks.
Regards,
2021-12-14 07:04 AM
Hi,
the DLL has been tested with an older version of VB.Net so I have no status with version 2019. The following module declaration has been used:
Module mod_CR95HFdll
Public Declare Function CR95HFDll_Echo Lib "CR95HF.dll" (ByVal mystring As String) As Long
Public Declare Function CR95HFDll_essai Lib "CR95HF.dll" (ByVal mystring As String) As Long
Public Declare Function CR95HFDll_Idn Lib "CR95HF.dll" (ByVal mystring As String) As Long
Public Declare Function CR95HFDll_Select Lib "CR95HF.dll" (ByVal mycmdstring As String, ByVal mystring As String) As Long
Public Declare Function CR95HFDll_SendReceive Lib "CR95HF.dll" (ByVal mycmdstring As String, ByVal mystring As String) As Long
Public Declare Function CR95HFDll_STCmd Lib "CR95HF.dll" (ByVal mycmdstring As String, ByVal mystring As String) As Long
Public Declare Function CR95HFDll_FieldOff Lib "CR95HF.dll" (ByVal mystring As String) As Long
Public Declare Function CR95HFDll_GetDLLrev Lib "CR95HF.dll" (ByVal mystring As String) As Long
Public Declare Function CR95HFDll_ResetSPI Lib "CR95HF.dll" (ByVal mystring As String) As Long
Public Declare Function CR95HFDll_SendIRQPulse Lib "CR95HF.dll" (ByVal mystring As String) As Long
Public Declare Function CR95HFDLL_getMCUrev Lib "CR95HF.dll" (ByVal mystring As String) As Long
'from DLL revision 0.4
Public Declare Function CR95HFDLL_getInterfacePinState Lib "CR95HF.dll" (ByVal mystring As String) As Long
'from DLL revision 0.5
Public Declare Function CR95HFDLL_USBconnect Lib "CR95HF.dll" () As Long
Public Declare Function CR95HFDll_Polling_Reading Lib "CR95HF.dll" (ByVal mystring As String) As Long
Public Declare Function CR95HFDll_SendNSSPulse Lib "CR95HF.dll" (ByVal mystring As String) As Long
'from DLL revision 0.6
Public Declare Function CR95HFDLL_USBhandlecheck Lib "CR95HF.dll" () As Long
'from DLL revision 0.9
Public Declare Function CR95HFDLL_getHardwareVersion Lib "CR95HF.dll" (ByVal mystring As String) As Long
End Module
I've seen a lot a posts about System.BadImageFormatException in various forums with many different solutions (32 bits version 64bits, version, path, etc.). Not an easy issue to solve.
Rgds
BT
P.-S. : updated status: tested ok with Visual Studio 15 VB.NET
2021-12-15 03:32 AM
Hi,
I could solve this problem setting the compilador to x86 (32 bits), but the library dont works well. Some functions respond but other not.
Functions as USB connect, Handlecheck work aparently well.
For example:
Public Declare Function CR95HFDll_GetDLLrev Lib "CR95HF.dll" (ByVal mystring As String) As Long
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim strAnswer As String = 0
Dim lngStatus As Long
lngStatus = CR95HFDll_GetDLLrev(strAnswer)
If (lngStatus = 0) Then
TextBox1.Text = strAnswer
Else
TextBox1.Text = "Error = no Dll found"
End If
TextBox2.Text = lngStatus
End Sub
In this case always get dll not found and the library dll was copied to system32 folder.
and other funtion that try to comunicate with STM or CH95RF work wrong or brake the code execution.
Maybe my code is not correct but i am using the code examples from: fan3954-developing-your-own-visual-basic-or-cc-application-on-a-cr95hf-demonstration-board-stmicroelectronics
Thnaks.
Regards,
2021-12-15 05:31 AM
Hi,
if USB connect or Handlecheck API are running fine, this means that the application can properly load the DLL. So this sounds strange that CR95HFDll_GetDLLrev returns an error except if the CR95HF.dll is an old one. Make sure to use the DLL from the latest STSW-95HF001 package. The date of modification of the DLL is 1/23/2017 4.58PM.
Rgds
BT
2021-12-15 11:55 PM
I have tried this but dont works. Same issues.
Maybe i need to work with Visual Studio 2015
Thanks.
Regards,
2021-12-16 05:33 AM
The functions that need return info dont work. So, could be a bad code programming.
The examples on documents dont work on Visual Basic .NET 2019 and i have tried with 2015 and the problem is the same.
Regards,
2021-12-16 05:34 AM
Hi,
another suggestion :
Using Visual Studio 2015, the format of DLL answer need to be formatted before to be used :
You must use this formatted variable in all functions to get DLL answer .
another suggestion : it is possible that Get DLL revision doesn't return "0" when you get DLL revision number.
You can can see the exact value with debug mode.
Hope this will help you,
Best regards,
NFC Customer support
2021-12-16 05:41 AM
That´s the solution. A correct format of variable declaration and Public declaration
Public Declare Function CR95HFDll_GetDLLrev Lib "CR95HF.dll" (ByVal mystring As String) As System.UInt32
Ok, thaks.
Problem solved