Hi
I have written a code in C# to load functions in an unmanaged dll.
This is the code.
class Program
{
static unsafe void Main(string[] args)
{
int deviceNr;
char* Info;
int intMyReturnVal;
deviceNr = 0;
Info = null;
intMyReturnVal = sample_getinfo(deviceNr, Info);
}
[DllImport("opcard2lib.dll")]
private unsafe static extern int sample_getinfo(int deviceNr, char* Info);
}
and this is the API function description by dll supllier.
1. Sample_GetInfo
Prototype:
DLLReturnType
Sample_GetInfo (int deviceNr,
char* Info);
Parameters:
deviceNr is a number of found card in system
Info is handler for string with information about current card in system
Returns:
Returns 0 (zero) when success. Otherwise return an error code.
Description:
This function provide information about installed card in system. Information returned
in Info string looks like below:
„SN YY.SN rev. RRR", where:
YY – year of production
SN – serial number
RRR – firmware revision
The problem is that when I run this code I get the bellow error exception:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
I have written this in VB.net to and get the same result.
I would appreciate your help.