title: CLR interfering with C++ STD?
body: <p>I have some code compiling under the clr and other code that is unmanaged in a single project.</p>
  
  <p>My common.h file includes all the std library headers that I need. It is included by manager.h (forward declaration for manager.cpp (no CLR)), which is included by main_window.h (WinForm) which is included by document_manager.cpp (CLR). </p>
  
  <p>At runtime I get all sorts of weird behavior, in one instance, my form wouldn't load. Pausing the program for debugging several times showed that it was stuck reallocating memory for a std::string, in malloc.c. By changing the code, I can recieve a System::InvalidMemory (I think) exception in ostream.</p>
  
  <p>How do I stop the CLR from managing the std library?</p>
  
  <p>If anyone would like the source to any of my files, just ask.</p>
  
  <p>Edit:
  In the callstack, I have some managed code that runs when my form loads. In the window init callback, I have a managed to native transition, and then my manager class. Later on, I get to</p>
  
  <pre><code>    std::string error_msg;
      error_msg = "Storage Manager: SQLite Error ("; &lt;-- Executing Currently
      error_msg += sqlite3_errcode(this-&gt;db_p);
      error_msg += ") - ";
      error_msg += sqlite3_errmsg(this-&gt;db_p);
      *(this-&gt;log) &lt;&lt; error_msg.c_str() &lt;&lt; std::endl;
  </code></pre>
  
  <p>and the callstack shows std::basic_string::assign, then some other std:: functions, and finally the malloc function, which it is perpetually stuck in.</p>
  
  <p>Edit:
  The exception that is thrown on file writing:</p>
  
  <pre><code>System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
     at manager.file_open(manager* , basic_string&lt;char\,std::char_traits&lt;char&gt;\,std::allocator&lt;char&gt; &gt;* )
     at DocumentManager.main_window.file_open_mainmenu_Click(Object sender, EventArgs e) in c:\development\document manager\document manager\main_window.h:line 456
     at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
     at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
     at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
     at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
     at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
     at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
     at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
     at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
     at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)
     at System.Windows.Forms.Control.WndProc(Message&amp; m)
     at System.Windows.Forms.ScrollableControl.WndProc(Message&amp; m)
     at System.Windows.Forms.ToolStrip.WndProc(Message&amp; m)
     at System.Windows.Forms.ToolStripDropDown.WndProc(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
     at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  </code></pre>