Assuming it works outside of a DLL, you're probably missing the runtime initialization calls. Mix SimpleDllMain in (or do your own). https://github.com/dlang/dmd/blob/9639d72ea0883808feff7aba71d87c5a78fb7f92/druntime/src/core/sys/windows/dll.d#L577