Dave Posted October 20, 2003 Posted October 20, 2003 I have a DLL which is compiled from C which I need to use in vb.net. So far I have this: Declare Auto Function UnCompress Lib "lzss.dll" Alias "_uncompress_data" (ByVal Data As String, ByVal Length As Integer) As String But when trying to run this: dim out as String = UnCompress(indata, len(indata)) I get the following error message: An unhandled exception of type 'System.NullReferenceException' occurred Additional information: Object reference not set to an instance of an object. The C declaration of this function is as follows: unsigned char __declspec(dllexport) *uncompress_data(unsigned char *inbuf,int *buflen) What am I doing wrong? Quote
vsnt Posted October 22, 2003 Posted October 22, 2003 Try This Declare Auto Function UnCompress Lib "lzss.dll" Alias "_uncompress_data" (ByVal Data As String, ByVal Length As Integer) As String UnCompress(indata, len(indata)) dim out as String = indata Quote
vsnt Posted October 22, 2003 Posted October 22, 2003 OK then try this Declare Function UnCompress Lib "lzss.dll" Alias "_uncompress_data" (ByRef Data As String, ByRef Length As Integer) As String UnCompress(indata, len(indata)) dim out as String = indata Quote
Administrators PlausiblyDamp Posted October 22, 2003 Administrators Posted October 22, 2003 What is the contents of the string you are passing in? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Dave Posted October 22, 2003 Author Posted October 22, 2003 well, it could be any string but it will actually be a file Quote
vsnt Posted October 22, 2003 Posted October 22, 2003 unsigned char ???? Could be that the dll function is looking for a char when you are passing it a string. Quote
Dave Posted October 23, 2003 Author Posted October 23, 2003 it's an array of chars, but changing the type to Char() makes no diffrence and if you change the returned type to Char() you get a 'Could not marshal the return data type' error Quote
Recommended Posts