I'm working on converting one of our systems from C++ to c#. We're still using a lot of our C++ libraries in the new system.
I'm pretty new to C++ and interop stuff but until now I've managed to get by. One particular piece of code has been troubling me for a while. One of the C++ methods I'm calling:
Calibration::GetValues(const VARIANT FAR& Data, long count)
isn't behaving as expected. With similar methods in the library passing in a System.Array works. With this, no matter what I do no new values are written to the array. When I step into the code the expected values are being calculated and (as far as I can tell with my limited knowledge of C++ and memory management) written to the array. The moment the method is exited the array returns to its previous state.
I'm calling the method using
Array ar = Array.CreateInstance(typeof(float), count);
values.GetValues(ar, count);
I'm sure the solution is something pretty simple but I can't seem to work out what's going on.
EDIT:
I had a look through the metadata and the method is declared as
int GetValues(object Data, int Count);
I'm still trying to figure out how Interop works but hopefully this is what was asked for