title: Array from C++ to C#
body: <p>I am trying to pass a double array (its actually a std::vector, but converted at transfer) from a c++ dll into a c# script (unity). 
  Using the approach outlined here <a href="https://stackoverflow.com/a/31418775">https://stackoverflow.com/a/31418775</a>.</p>
  
  <p>I can successfully get the size of the array printing on my console in unity   however I am not able to use "CoTaskMemAlloc" to allocate memory for the array since I am using Xcode and it doesnt seem to have COM. </p>
  
  <p>For a little more background this array is part of a control for a GUI, c++ creates it and the user edits with the c# GUI - so the plan is to be able to pass the array back to c++ when it has been edited.</p>
  
  <pre><code>C++ code
  extern "C" ABA_API void getArray(long* len, double **data){
      *len = delArray.size();
      auto size = (*len)*sizeof(double);
      *data = static_cast&lt;double*&gt;(CoTaskMemAlloc(size));
      memcpy(*data, delArray.data(), size);
  }
  
  C# code 
  [DllImport("AudioPluginSpecDelay")]
  private static extern void getArray (out int length,[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] out double[] array);
  
  int theSize;
  double[] theArray;
  getArray(out theSize, out theArray);
  </code></pre>
  
  <p>If I leave out the code concerning the array, the int passes just fine. So I beleive the method to be the right one, its just getting around the lack of CoTaskMemAlloc. </p>