I found out that I can make an array in the C# exe and pass it as a parameter to a dll fuction. When the function is done, array members are changed so I don't need to send anything back to the exe. The only problem is that it doesn't work for two-dimensional arrays. I tried it and the compiler showed no errors, but at debug the message magically appeared: "Object reference not set to an instance of an object". Here's what I did:
C# exe:
[DllImport("ZdravoDll.dll")]
public static extern void DllFunction(int[,] nesto);
int[,] field=new int[301, 301];
...
...
DllFunction(field);
...
------------------------------------------
C++ dll:
void DllFunction(int *polje[])//or polje[301][301], the result is the same
{
...
}
I'm beginning to think that it can't be done. MarshalAs attribute doesn't have an unmanaged type for a two-dimensional array. LPArray is for one-dimensional arrays only (if I understood it correctly). Anyway, if anyone knows ANYTHING about this, please reply!