I have a problem with a variable type from a dll which i am importing in C#. It is written in object oriented pascal and it says it is developed with the Delphi Development Tool.
On the manual of the library it says that shortstring
is a packed array of bytes. The first byte is the length and the following are exaclty 255 bytes with the string data that i need.
So after importing the dll in C# i wrote:
[return: MarshalAs(UnmanagedType.LPArray)]
Then called the function from the dll:
public static extern byte[] xxxx();
But i am getting the following error:
Cannot marshal 'return value': invalid managed/unmanaged type combination
On the other hand i tried the following:
[return: MarshalAs(UnmanagedType.SafeArray)]
This time i get the error:
SafeArray of rank 18727 has been passed to a method expecting an array of rank 1
Can you please tell me what i am doing wrong, and firstly is correct like this to get a shortstring from a compiled library?
Regards