R
richard.brenner
Hi There.
I try to implement methos from an unmanaged DLL in C# to get access to
an external device.
I have a problem with the following C method:
char* __stdcall RDR_SendCommandGetData(void* hReader, char* command,
char* data, char* buffer);
My C# counterpart:
[DllImport("Reader.dll",CharSet=CharSet.Ansi,SetLastError=true)]
internal static extern string RDR_SendCommandGetData(IntPtr hReader,
string command, string data,StringBuilder buffer);
I get an error at the following call:
output=ReaderBinding.RDR_SendCommandGetData(reader,command,commandvalue,buffer);
The error is:
An unhandled exception of type 'System.NullReferenceException'
occurred in testapp.exe
Additional information: Object reference not set to an instance of an
object
In order to get and receive data, I previously have to open the Reader
device and receive the handle.
The methods are:
C:
void* __stdcall OpenComm(char* commDevice, char autodetect, struct
presetSettings* settings);
C#:
[DllImport("Reader.dll",SetLastError=true,CharSet=CharSet.Ansi)]
internal static extern IntPtr RDR_OpenComm(System.String device,int
autodetect, presetSettings settings);
call:
IntPtr reader;
reader=ReaderBinding.RDR_OpenComm("COM5",1,null);
I tried setting some ref and out attributes but it doesn't change the
error.
Please help.
Thanks.
I try to implement methos from an unmanaged DLL in C# to get access to
an external device.
I have a problem with the following C method:
char* __stdcall RDR_SendCommandGetData(void* hReader, char* command,
char* data, char* buffer);
My C# counterpart:
[DllImport("Reader.dll",CharSet=CharSet.Ansi,SetLastError=true)]
internal static extern string RDR_SendCommandGetData(IntPtr hReader,
string command, string data,StringBuilder buffer);
I get an error at the following call:
output=ReaderBinding.RDR_SendCommandGetData(reader,command,commandvalue,buffer);
The error is:
An unhandled exception of type 'System.NullReferenceException'
occurred in testapp.exe
Additional information: Object reference not set to an instance of an
object
In order to get and receive data, I previously have to open the Reader
device and receive the handle.
The methods are:
C:
void* __stdcall OpenComm(char* commDevice, char autodetect, struct
presetSettings* settings);
C#:
[DllImport("Reader.dll",SetLastError=true,CharSet=CharSet.Ansi)]
internal static extern IntPtr RDR_OpenComm(System.String device,int
autodetect, presetSettings settings);
call:
IntPtr reader;
reader=ReaderBinding.RDR_OpenComm("COM5",1,null);
I tried setting some ref and out attributes but it doesn't change the
error.
Please help.
Thanks.