Issue loading unmanaged dll in Editor on Windows 10

I’m wondering if anyone has come across this recently. I just updated to Windows 10 from 8.1. I routinely use C DLLs to communicate with hardware such as motion platforms, both in editor and builds.

After upgrading to Win10 I get EntryPointNotFoundException whenever I try to load a DLL in the Editor. Filexists show that the file is there and Dumpbin shows no mangling of names has occurred. The exact same project worked fine in the Editor under Windows 8.1, and it also works in Windows 10 when I build it.

I have experimented with recompiling the DLL with different calling conventions, different target platform and different VC versions and so on but I get the same EntryPointNotFoundException on my functions whatever I seem to do. I also get the same exception if I remove the file entirely. I would expect a FileNotFoundException then but that is not the case, even though Fileexists shows false in that case. I have the Visual C++ runtimes installed of course. Using DLLs this way has worked for years, but immediately when upgrading to Windows 10 I get this, and it is annoying not being able to run motion platforms from the Editor when doing queuing etc.

This is the same with all versions I have tried, 5.4, 5.5 and 5.6 with Windows 10, and all projects including minimal builds simply calling a single DLL function. I reinstalled Unity as well, tried Win 8 compatibility mode, but all the same. I wonder if there is some way Windows 10 is stricter in how it loads DLLs that affects the Editor but not builds or if there is something else I have missed.

Any idea would be very appreciated.

It works if I hard-code the FULL path in DllImport. This means when running in Editor, the intended relative function of this is not working. Even when I import Kernel32 and call SetDllDirectory and LoadLibrary, it did nothing to change this.

For now it’s fine though since I am mainly working on the projects myself. I just use #if UNITY_EDITOR to specify a hard coded full path when in editor, and a normal relative path when in build. As I mentioned this behavior happened with an upgrade from Win 8.1 to 10, so I think there is something that affects how the Editor can call dlls.

FYI I also tested this on another system with Win 10 and got the same result there, so it is not limited to my system. It’s not life-threatening in this case, but annoying nonetheless.