title: Marshal.StructureToPtr crashes Visual Studio
body: <p>I'm working on a custom debug engine and when I marshal my structure to a <code>IntPtr</code> Visual Studio crashes (the one being debugged not the debugger).  </p>
  
  <p>My struct is little more than:</p>
  
  <pre><code>public struct DocumentContext : IDebugDocumentContext2, IDebugCodeContext2
  {
      private string _fileName;
  
      //.....Implementation of interfaces
  }
  </code></pre>
  
  <p>My marshalling code looks like this:</p>
  
  <pre><code>        var documentContext = new DocumentContext(_node.FileName);
          var size = Marshal.SizeOf(documentContext);
          IntPtr ptrDocContext = Marshal.AllocHGlobal(size);
          //This is what is crashing 
          //I don't have a chance to catch anything, it just craps out
          //Event log says faulting dll is nt.dll
          Marshal.StructureToPtr(documentContext, ptrDocContext, true); 
  </code></pre>
  
  <p>Am I missing something?</p>