C shortString to c# type

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

Can you please tell me what i am doing wrong, and firstly is correct like this to get a shortstring from a compiled library?


Source: c++

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.