how to save the ARRAY returned by C DLL from C sharp
i new programing ...
i want save array returned c dll c sharp array
my code fallows
1.c dll
extern "c"
{
__declspec(dllexport)
int* main(int a1[], int a2[] ,int row1,int col1,int col2)
{
................................
................................
................................
int * =(int) malloc(sizeof(int)*k);
...........................
return a;
}
}
and c sharp program fallows.
[dllimport("f:\\just it\\cuda\\gpumul\\gpumulgui\\resource\\gpumul.dll")]
[return: marshalas(unmanagedtype.lparray )]
public static extern intptr main(int[] k1, int[] k2, int x, int y, int z);
public static int[] getarray()
{
int size = 10
int x = 8
int y = 7
int z =8
intptr array = main(matrixone, matrixtwo, x, y, z);-----------------run time error here "int/uint must paired sysint or sysuint).
int[] marray = new int[size];
marshal.copy(array, marray, 0, size); // plz check this
// marshal.freehglobal(array); //free unmanaged array
return marray;
}
.NET Framework > Common Language Runtime Internals and Architecture
Comments
Post a Comment