title: Error running code from DLL in C#
body: <p>I can't seem to get past this error, so I'm wondering if I'm doing anything wrong in my call code, or my DLL?</p>
  
  <p>-Error-</p>
  
  <pre><code>$exception  {System.BadImageFormatException: The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)
  </code></pre>
  
  <p>-call code-</p>
  
  <pre><code> Assembly assembly = Assembly.LoadFile(@"C:\Users\Admin\Documents\Visual Studio 2012\Projects\MyDLL\Release\myDLL.dll");
              Type type = assembly.GetType("HelloWorld");
              var obj = Activator.CreateInstance(type);
  
              // Alternately you could get the MethodInfo for the TestRunner.Run method
              type.InvokeMember("HelloWorld",
                                BindingFlags.Default | BindingFlags.InvokeMethod,
                                null,
                                obj,
                                null);
  </code></pre>
  
  <p>-DLL code-</p>
  
  <pre><code>#include &lt;Windows.h&gt;
  
  using namespace std;
  
  extern "C" _declspec(dllexport) void __stdcall HelloWorld(LPSTR title, LPSTR msg)
  {
     MessageBox( NULL, msg, title, MB_OK);
  }
  
  BOOL APIENTRY DllMain( HMODULE hModule,
                         DWORD  ul_reason_for_call,
                         LPVOID lpReserved
                       )
  {
      switch (ul_reason_for_call)
      {
      case DLL_PROCESS_ATTACH:
      case DLL_THREAD_ATTACH:
      case DLL_THREAD_DETACH:
      case DLL_PROCESS_DETACH:
          break;
      }
      return TRUE;
  }
  </code></pre>