I recently had this problem, and I think I've solved it for now if anyone is still looking for a fix ... it's really ghetto but it seems to work for me.
extern (Windows) BOOL DllMain(HMODULE hModule, ULONG ulReason, LPVOID pvReserved) { if(ulReason == DLL_PROCESS_ATTACH) { DllMainReal(hModule); core.memory.GC.collect(); //collect garbage before the return asm { mov EAX, 1; ret; // Don't give the garbage collector the chance to make things messy } } return TRUE; }