title: How to call C++ DLL in C#
body: <p>I have written a DLL in dev C++. The DLL's name is "DllMain.dll" and it contains two functions: <code>HelloWorld</code> and <code>ShowMe</code>. The header file looks like this:</p>
  
  <pre><code>DLLIMPORT  void HelloWorld();
  DLLIMPORT void ShowMe();
  </code></pre>
  
  <p>And the source file looks like this:</p>
  
  <pre><code>DLLIMPORT void HelloWorld ()
  {
    MessageBox (0, "Hello World from DLL!\n", "Hi",MB_ICONINFORMATION);
  }
  
  DLLIMPORT void ShowMe()
  {
   MessageBox (0, "How are u?", "Hi", MB_ICONINFORMATION);
  }
  </code></pre>
  
  <p>I compile the code into a DLL and call the two functions from C#. The C# code looks like this:</p>
  
  <pre><code>[DllImport("DllMain.dll", CallingConvention = CallingConvention.Cdecl)]
  public static extern void HelloWorld();
  
  [DllImport("DllMain.dll", CallingConvention = CallingConvention.Cdecl)]
  public static extern void ShowMe();
  </code></pre>
  
  <p>When I call the function "HelloWorld" it runs well and pops up a messageBox, but when I call the function <code>ShowMe</code> an <code>EntryPointNotFoundException</code> occurs. How do I avoid this exception? Do I need to add <code>extern "C"</code> in the header file?</p>