Application Error - Memory could not be "read"

  • Thread starter Ryan Linneman via .NET 247
  • Start date
R

Ryan Linneman via .NET 247

Any help appreciated...

I am using a third party DLL file to access an HMI using ethernet. The function is declared in a VB module as:

'Read internal word address
Public Declare Function HKEtn_ReadInternalMemory Lib "HKEserv.dll" _
(ByRef dp As Int16, _
ByVal Wordcnt As Int16, _
ByVal DeviceType As Int32, _
ByVal addr As Int32, _
ByVal lpAddr As String, _
ByVal fg As Int32) _
As Int32

When I run this function in a single-threaded application, all is good. When I run the function in a multi-threaded application, I get an error message in a message box on closing the app:

myApplication.exe - Application Error

The instruction at "0x6c3b5115" referenced memory at "0x00000004". The memory could not be "read".

Click OK to terminate the program

Could the DLL be incompatible with .NET environment? Is it that I am not cleaning up some unmanaged resources?

I'm flat out of ideas...

Thanks...
 
K

Kaoru Kodaka

Dear Ryan,

Show me a declaration for this API in header file. I guess
first argument is something wrong.
 
C

Chris Dunaway

Since it's a multi-threaded app, are you making sure that none of your
threads are still running when the app closes? Could one of the
threads be trying to access an object that is no longer available?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top