passing array of structs from c# to regular dll

Posted by buzz on Stack Overflow See other posts from Stack Overflow or by buzz
Published on 2009-11-19T02:54:07Z Indexed on 2010/03/31 6:03 UTC
Read the original article Hit count: 264

Filed under:
|
|
|

Hi there I have a regular dll with the followign fucntion exported.

extern "C" __declspec(dllexport) int FindNearestStuff(double _latitude, double _longitude , LocationStruct * locations[])

LocationStruct is very simple

struct LocationStruct
  {
   long positionIndex;
   long item;
  };

I'm tryign to call it from c# using

 [DllImport("myclever.dll", CharSet = CharSet.None)]
        private static extern int FindNearestStuff(double _latitude, double _longitude, 
                                                    ref LocationStruct [] locations);

Its all cool and funky and i can step into the dll function from the debugger. Inside the dll the LocationStruct array is populated correctly and all is very good.

the problem i have is when it returns back from the dll, the LocationStruct array is not coming back with the data - just empty values...

what am i missing?

cheers

Buzz

© Stack Overflow or respective owner

Related posts about c#

Related posts about arrays