Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, July 24, 2013 3:27 AM
Hi,
I have to load multiple DLLs of from my exe. When i tried to load DLLs of size more than 50kb ,loadlibrary api geeting failed and getlasterror() returning error code 126.If i tried to load the same DLL by reducing its size(commanded some partn of code), its loading that DLL properly.
Can anyone guess the problem with my application. I can able to load the same DLL in debug mode and through IDE but while running exe, its giving memory exception since loadlibrary returns a null pointer.
can anyone help me to to fix this problem ?
All replies (7)
Monday, August 12, 2013 7:21 AM âś…Answered
Hi guys,
Thanks for your replies.
I found the issue , that is because of missing dlls that are needed to execute my application from exe.
Once i added that dependent dll's, my application working fine.
Wednesday, July 24, 2013 6:07 AM
Hi,
one reason for this error can be a missing dependency. You could use the tool dependency walker to check the dependencies of your dll. (http://flashexperiments.insh-allah.com/ApacheError126.html might be usefull to see how you could track this down.)
It could also help to use the process monitor tool to see what files windows tries to open when it tries to load the library (http://technet.microsoft.com/en-us/sysinternals/bb896645)
With kind regards,
Konrad
Wednesday, July 24, 2013 6:36 AM
Hi Konrad,
If the problem is missing dependecy, it should not load the same DLL after reducing its size. But it loaded the DLL from same exe without any configuration change. Is that tool useful in tracking memory related problems?
Wednesday, July 24, 2013 7:21 AM
Dear Kornad,
I have to add up some more details here.
When i tried to run exe in debug mode or through IDE in release mode , my application working fine.If i tried with exe in release mode, its not loading some of the DLL(that are of size more than the exe).
Wednesday, July 24, 2013 9:58 AM
Hi,
as far as I know there is no limitation regarding size when loading a DLL (At least not at 50KB. There are limitations regarding memory of course but these do not apply in this small regions.).
I really recommend to check with dependency walker and with the process monitor. The error code 126 is this ERROR_MOD_NOT_FOUND so something that is required is not found.
And also be aware that the linker is doing a lot of optimizations. I have no details what you are doing exactly but some explanation could be:
- When you comment parts of the code (to make the DLL smaller) it works, because the linker is optimizing the result and is removing dependencies that are not used
- The compiler and linker flags are different between Debug and Release. Maybe you even have some precompiler directives inside the code which makes the debug and release 2 different applications.
So it could be a nice try to compare the dependencies of the different DLLs:
- the debug compiled DLL that is working
- the release compiled DLL that is not working
- the release compiled DLL with code commented out that can be loaded.
Maybe you can find the reason for the error that way. Or you simply try to start the release compiled version that fails and check what is going on with the process explorer.
With kind regards,
Konrad
Wednesday, July 24, 2013 10:15 AM
Dear All
Till now i have not received a suitable answer. Hence i am clarifying the question once more.
I have created some dlls and i am trying to load all the dlls dynamically in a win32 console application. While running the exe, by double clicking it, i have observed that some dlls are loading sucessfully while some dlls are not loading, and the load library api is returning NULL, and the getLastError is returning a error of 126. If i tried to run the exe from the IDE, the dlls are loaded sucessfully.
I have also observed that the size of the dlls that are not being loaded sucessfully is large as compared to the dlls that are loaded sucessfull. If i reduce the size of the same dlls by commenting some code in the dll, it is sucessfully loaded.
Request you to give some solution.
Regards
Vanitha
Wednesday, July 24, 2013 11:35 AM
Sorry that you find my replies not helpful at all. I would still recommend to simply go and check the dependencies and also check what the process monitor will give you.
(Now I understood that it works when called from the IDE. You are calling the DEBUG version only or also the RELEASE version? If the RELEASE version works when called form the IDE and does not work when called outside, then the reason could be, that a dependency is not found. The IDE starts the application in a changed environment.)
I helped you as much as I could. Good luck with finding the reason for your problems. (Maybe a last hint: Maybe you simply try out what others are telling you.)
With kind regards,
Konrad