title: Call C++ function in C# from DLL - strange parameters
body: <p>I have a function writen in C++ with the next header:</p>
  
  <pre><code>void EncodeFromBufferIN(void* bufferIN,int bufferINSize, unsigned char*  &amp;bufferOUT, int &amp;bufferOUTSize);
  </code></pre>
  
  <p>I've edited the .h and .cpp files like this, to be able calling the function by importing the DLL in C#:</p>
  
  <pre><code>**EncodeFromBufferIN.h**
  extern "C" {
       __declspec(dllexport) void EncodeFromBufferIN(void* bufferIN, int bufferINSize, unsigned char*  &amp;bufferOUT, int &amp;bufferOUTSize);
  }
  **EncodeFromBufferIN.cpp**
  extern void EncodeFromBufferIN(void* bufferIN, int bufferINSize, unsigned char*  &amp;bufferOUT, int &amp;bufferOUTSize){
      // stuff to be done
  }
  </code></pre>
  
  <p>But now my problem is that I don't know how to call the function in C#. I've added the next code in C# but not sure how to pass the parameters to the function. </p>
  
  <pre><code>[DllImport("QASEncoder.dll")]
          unsafe public static extern void EncodeFromBufferIN(void* bufferIN, int bufferINSize, out char[] bufferOUT, out int bufferOUTSize);
  </code></pre>
  
  <p>The bufferIN and bufferOUT should be strings but if I'm calling the function like this:</p>
  
  <pre><code>public string prepareJointsForQAS()
  {
     string bufferIN = "0 0 0 0 0";
     char[] bufferOUT;
     int bufferOUTSize;
     EncodeFromBufferIN(bufferIN, bufferIN.Length, bufferOUT, bufferOUTSize);
  }
  </code></pre>
  
  <p>I get this error: "The best overloaded method matrch for ... has some invalid arguments". So how should the parameters be passed?</p>