Currently, I'm using LoadLibrary function to load my xxx.dll file (xxx.dll is my private dll file). It works normally, however, sometimes it fails to load library with error code 126.
MyDll = LoadLibrary(DllPath.c_str());
DllPath (of type std::wstring) is the path to my dll file.
I researched the error and it means that "The module could not be found", but I checked that the directory is right and the dll file still exists.
My dll file is a 32 bit dll and OS is windows 64 bit and dll file is loaded when starting service.
It rarely happens and currently I cannot reproduce this error. However, whenever the error happens, it will be always failed to load dll file and there is only one way to fix this is removing and reinstalling the software.
Does anyone know what is the possible reason of this issue?
Any help is appreciated!
whileloop (with a maximum number of attempts) until the DLL is loaded successfully, and sleeping a random time between attempts (duration 10-1000 ms, not a problem for me as I'm in a thread dedicated to loading large DLLs, which is going to be blocking for a non-trivial time anyways). - John Weisz