title: Unable to find an entry point when calling C++ dll in C#
body: <p>I am trying to learn P/Invoke, so I created a simple dll in C++</p>
  
  <p>KingFucs.h:</p>
  
  <pre><code>namespace KingFuncs
  {
      class KingFuncs
      {
      public:
          static __declspec(dllexport) int GiveMeNumber(int i);
      };
  }
  </code></pre>
  
  <p>KingFuns.cpp:</p>
  
  <pre><code>#include "KingFuncs.h"
  #include &lt;stdexcept&gt;
  
  using namespace std;
  
  namespace KingFuncs
  {
      int KingFuncs::GiveMeNumber(int i)
      {
          return i;
      }
  }
  </code></pre>
  
  <p>So it does compile, then I copied this dll into my WPF's debug folder, with code:</p>
  
  <pre><code>[DllImport("KingFuncDll.dll", EntryPoint = "GiveMeNumber", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
          public static extern int GiveMeNumber(
                int i
                );
  </code></pre>
  
  <p>And calling it in button click:</p>
  
  <pre><code>private void Button_Click(object sender, RoutedEventArgs e)
  {
      int num = GiveMeNumber(123);
  }
  </code></pre>
  
  <p>But it gives me exception:</p>
  
  <blockquote>
    <p>Unable to find an entry point named 'GiveMeNumber' in DLL
    'KingFuncDll.dll'.</p>
  </blockquote>
  
  <p>Really.... what have I done wrong... It obviously able to find the DLL, otherwise would be another exception.  But my method name is exactly the same.... I can't think of other reason.</p>