title: dll in debug mode, calling program in release mode (and vice versa)
body: <p>I'm writing a small C++ program that tests C dlls, containing some functions. Those dlls exist in a debug version and a release version and I would like to load them both with the same program and compare them with a previous version. </p>
  
  <p>The problem is, when I compile my program with release config, it can only use the dlls that are also release, and when I compile the program using debug config it can only use dlls that are also debug. </p>
  
  <p>I load the dlls/functions using LoadLibrary and GetProcAddress functions. </p>
  
  <p>There are two types of functions:
  <code>void type1(int&amp;)</code> and <code>void type2(vector&lt;string&gt;*)</code>.
  Type 1 works fine no matter the configuration.
  But type 2 only works when the configuration matches. </p>
  
  <p>Code:
  <code><pre>
  typedef void(*GetNames)(vector<code>&lt;string&gt;*</code>);
  GetNames get_var_names = (*GetNames)GetProcAddress(dll,"get_var_names");
  vector<code>&lt;string&gt;</code> var_names;
  get_var_names(&amp;var_names);
  </pre></code></p>
  
  <p>The last line is where the program fails with an error like "0xC0000005: Access violation reading location 0xbaadf008." if the configuration of calling program and dll don't match.
  The error is a reading violation when program is release and dll is debug, but a writing violation when program is debug and dll is release.</p>
  
  <p>What the function is supposed to do is just call push_back("x") a few times with different strings.</p>
  
  <p>It doesn't seem to be totally impossible to use a debug dll in a release config program or all the functions of type 1 also wouldn't work, so it seems to have something to do with vector or string class. </p>
  
  <p>Anyone have any idea how to solve this or is using two executables with different configurations my only choice?</p>