title: call unmanaged C++ code from C# using pinvoke
body: <p>I have a unmanaged C++ dll for which I do not have access to code but have all methods declarations for.</p>
  
  <p>Lets for simplicity say that .h looks like this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  #ifndef NUMERIC_LIBRARY
  #define NUMERIC_LIBRARY
  
  class Numeric
  {
      public:
          Numeric();
          int Add(int a, int b);
          ~Numeric();
  };
  
  #endif
  </code></pre>
  
  <p>and method implementation in .cpp file</p>
  
  <pre><code>int Numeric::Add(int a, int b)
  {
      return (a + b);
  }
  </code></pre>
  
  <p>I simply want to call the add function from C++ in my C# code:</p>
  
  <pre><code>namespace UnmanagedTester
  {
      class Program
      {
          [DllImport(@"C:\CPP and CSharp Project\UnmanagedNumeric\Debug\numeric.dll", EntryPoint = "Add")]
          public static extern int Add(int a, int b);
  
  
          static void Main(string[] args)
          {
              int sum = Add(2, 3);
              Console.WriteLine(sum);
  
          }
      }
  }
  </code></pre>
  
  <p>After trying to execute I have the following error:</p>
  
  <p>Unable to find an entry point named 'Add' in DLL 'C:\CPP and CSharp Project\UnmanagedNumeric\Debug\numeric.dll'.</p>
  
  <p>I CAN NOT change C++ code. Have no idea what is going wrong.
  Appreciate your help.</p>