To describe the problems I've been having would take too long, but the the problem at the sharp end is:
LoadLibraryW fails (returns nullptr) when given a valid path.
Process Monitor records no suspicious failures, or indeed anything different from when it succeeds in loading the dll (which it can in another context).
The dll has no non-system dependencies.
...and worst of all, the Windows error code returned by GetLastError is 3221225619.
Assuming that 3221225619 is not a valid error code, what could be going so wrong that Windows doesn't even have an error code for it?
EDIT:
I think some people have wanted more details on the failure itself:
Sorry, this is not exactly an answer, but the issue has been resolved.
To start with, I've just noticed a similar question here: C++ Loadlibrary() error 3765269347 . I think this one gives more details, and is worth a look if you're in a similar position to what I was.
My thanks to @WhozCraig, @DanielDaranas and everybody else who made helpful comments. For other people reading this, there is a good article on HRESULT which expands on their points on Wikipedia: http://en.wikipedia.org/wiki/HRESULT .
In my case, the problem has gone away as mysteriously as it arose. I have created a C++ class to call the dll on a regular basis. My original effort loaded the dll immediately before the first call, and cached it in memory. This is the same in principle to how it's worked for over a year. This resulted in the mysterious error above.
I have refactored it to load the dll during construction, but to only extract the function from it at run time. This apparently works, and is probably a better way of doing it (loading the dll during construction, freeing it during destruction). As there is very little going on between the construction and the first call to the dll, I cannot see why one method should produce a OS error, and the other does not.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.