Click here to Skip to main content
16,007,843 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello,

I need to write-read from a program to a RFID USB Card Writer.

The Card Writer is deliverd with a DLL 32 bit which has certain function.

When trying to call funtions from the DLL there is always a error coming up 'Access Violation Exception was unhandled when calling a DLL'

I am not familiar with dll's so does anyone has a idea.

Maybe the DLL is not working for .net 2008 there are examples deliverd for VB6 an VC but not for .net. The supplier of the RFID reader has not specified that it wont work with win7 but since i got errors.

I have taken a windows 7 and installed a old VB6 on it (there where errors when installing that VB6 is is not compatible with win7) but the installation is working.

So i have used the example on this machine in VB6 and there the reader is responding and gives no error.


I use this on Windows 7 32 bit version.

Can anyone give me some advise please

VB6 Code that is working

VB
hexkey = "ffffffffffff"
st = dc_load_key_hex(ByVal icdev, 0, 1, ByVal hexkey)  'Load Key of Sector 1 to the Reader,correspond to the following authentication
If st <> 0 Then
      List1.AddItem ("dc_Load_key_hex Error!")
      Exit Sub
End If
List1.AddItem ("dc_Load_key_hex OK!")



VB .Net 2008 Code with the access Violation Exception

VB
hexkey = "ffffffffffff"

        st = dc_load_key_hex(icdev, 0, 1, hexkey)  'Load Key of Sector 1 to the Reader,correspond to the following authentication
        If st <> 0 Then
            TextBox1.Text = "dc_Load_key_hex Error!"
            Exit Sub
        End If
        TextBox1.Text = "dc_Load_key_hex OK!"





Anyone with a good hint ?

I am wondering if the DLL might be not compatible with .net ? can this be the problem ?

Thanks.

Didier
Posted
Updated 7-May-11 22:48pm
v2

1 solution

1- please add detailed exception.StackTrace and innerException
2- it may be because the DLL is doing some memory operation and not trusted. you need to look at what need to be set in CAS so that you can make this dll trustworthy.
http://msdn.microsoft.com/en-us/library/Aa480472[^]

Regards,
Hemant
 
Share this answer
 
Comments
Didier Cauberghe 8-May-11 14:09pm    
Hello,

Since i am new about this could you explain is a little please.

I dont know what you are suggesting.

Thanks

Didier
Hemant__Sharma 10-May-11 14:50pm    
try this suggestion
http://www.gamedev.net/topic/270670-pinvoke-callback-access-violation/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900