title: Can't use/debug unmanaged DLL from C#
body: <p>I have a C# application and a C++ DLL, both x86. The Application is the startup project, the DLL project is inside the same solution and is referenced as a project. The C++ DLL outputs its PDB file with the same name as the DLL inside the Debug folder of the Application.</p>
  
  <p>I have a function called <code>SomeFunction</code> that I'm trying to execute in C#. When the code reaches that line, it stops there. The UI of the C# application continues to be responsive, but the breakpoint never leaves that line (and that's in Form_Load).</p>
  
  <p>If I try to set the DLL as startup project and tell it to execute the C# application, then C# will crash at that line with: System.EntryPointNotFoundException: Unable to find an entry point named 'SomeFunction' in DLL 'SomeDLL.dll'.</p>
  
  <p>This is the declaration of the function that I'm trying to call:</p>
  
  <pre><code>[DllImport("SomeDLL.dll", EntryPoint = "SomeFunction", CallingConvention = CallingConvention.Cdecl)]
  public static extern int SomeFunction(IntPtr hwnd);
  </code></pre>
  
  <p>This is the function's declaration from the C++ header:</p>
  
  <pre><code>#define MYDLL_API __declspec(dllexport)
  MYDLL_API extern int SomeFunction(HWND hWnd);
  </code></pre>
  
  <p>This is how I call it from C#:</p>
  
  <pre><code>var someAnswer = SomeFunction(_hwnd);
  </code></pre>
  
  <p><strong>UPDATE</strong>: since the discussion below could take some time to read, here's the answer in the nutshell: I was missing an extern "C". Also, in order to debug the DLL (which was also a problem), the project needs to support native debugging both from C++ and C#, here's an excellent list that I went through and at the end it was all good!</p>
  
  <p><a href="https://stackoverflow.com/questions/3535075/no-symbols-loaded-in-mixed-c-sharp-cwin32-project-using-vs2010">No Symbols loaded in mixed C# C(win32) project using VS2010</a></p>