You don't need the C++/CLI library is this case, pinning a multidimensional array is harder than just pinning a one-dimensional array as you need to pin the inner arrays manually.
If you do it with C#, the compiler does it automatically for you.
With C#, you can do this:
[DllImport('legacylibrary.dll')]
public static extern int LegacyGetVariableValues(double[][] timeValues);
For further reading, check http://msdn.microsoft.com/en-us/library/fzhhdwae(v=vs.110).aspx
Edit:
As you need the C++/CLI layer, you need to do something like this:
ref class Legacy {
public:
int GetVariableValues(array<array<double> ^> ^values) {
array<GCHandle> ^handles = gcnew array<GCHandle>(values->Length);
double **valuesPtr = calloc(sizeof(double *), values->Length);
int result;
for (int i = 0; i < values->Length; i++) {
handles[i] = GCHandle::Alloc(values[i]);
valuesPtr[i] = (double *)GCHandle::ToIntPtr(handles[i]).GetPointer();
}
result = LegacyGetVariableValues(valuesPtr);
for (int i = 0; i < values->Length; i++) {
handles[i].Free();
}
return result;
}
}
PS: Don't know if the syntax is completely correct as I don't write C++/CLI in a long time.
GetVariableValueswould hold on return (logically)? a pointer to array of doubles? a two-dimensional array of doubles? But most importantly - how on earth can the runtime determine how much elements are in the array?