I'm working on a custom debug engine and when I marshal my structure to a IntPtr
Visual Studio crashes (the one being debugged not the debugger).
My struct is little more than:
public struct DocumentContext : IDebugDocumentContext2, IDebugCodeContext2
{
private string _fileName;
//.....Implementation of interfaces
}
My marshalling code looks like this:
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);
Am I missing something?