title: Importing C++ custom library functions into C#
body: <p>I currently have a large C++ library that I need to incorporate into a C# project. I was successful in using <code>DllImport</code> to get access to some functions from my library, like this:</p>
  
  <pre><code>[DllImport("MyLib.dll")]
  public static extern int SampleFunction(string param);
  </code></pre>
  
  <p>However, I can't seem to figure out how to make it work for functions that either have a parameter or return type that is not defined within the dll itself (i.e., the code in the dll imports it from another file), such as this example function that takes in a list:</p>
  
  <pre><code>[DllImport("MyLib.dll")]
  public static extern std::vector&lt;MyClass&gt; MyFunction(string param);
  </code></pre>
  
  <p>For std library functions, I know I can get the dll and import that in, but what about other classes like MyClass in the above example? Do I need to create a managed wrapper class in C++ for each of these classes, or is there another way to do this?</p>