LoadLibrary() fails with Error code 127
Question
Saturday, January 14, 2012 2:10 PM
Hi,
We have one dll and one exe codes with is ported from VC++6.0 to VC
++ 2005.
We need to convert it(VC++ 2005) to VC++ 2010( VS 2010) to take advantages of latest enhanced MFC libraries.
Converted both codes to 2010.But when trying to load that new compiled dll to the new compiled exe ,LoadLibrary Function
failed with Error code 127.
While in VS 2008 same thing is working.
Calling LoadLibraryEx with DONT_RESOLVE_DLL_REFERENCES option dll loaded,but when call GetProcAddress it failed with
127.
Do we need to set some special configuration to make this working.
Thank you.
Regards,
Jignesh
All replies (4)
Saturday, January 14, 2012 4:07 PM ✅Answered
Jigs Patel wrote:
Converted both codes to 2010.But when trying to load that new compiled dll to the new compiled exe ,LoadLibrary Function
failed with Error code 127.
Your DLL depends on some other DLL and expects it to export some function, which turns out not to be there. Dependency Walker (http://dependencywalker.com) should be able to show missing dependencies.
Igor Tandetnik
Tuesday, January 17, 2012 7:21 AM ✅Answered
Hi Jignesh,
Welcome to the MSDN Forum.
After researching on the issue for a while, I found that error 127 indicates that there is an appropriate DLL found but a required procedure export is missing. To find more information about this issue, I would like to suggest you have a try on Dependency Walker and DUMPBIN.exe. You can use Dependency Walker tool to scan the Visual C++ application to find out which DLL was not loaded. And dumpbin.exe can help you check whether there are symbols output from your DLL.
In addition, C++ compiler generally change the function names in a DLL, and extern "C" can ensure the names not be changed. And if we want to export a function or class from a DLL, we should put "_declspec (dllexport)" before the name. Please take a look at this line:
extern "C" _declspec(dllexport) int add(int a,int b);
I hope this reply is helpful to you. If you have any questions, please feel free to let us know.
Best regards,
Helen Zhao [MSFT]
MSDN Community Support | Feedback to us
Monday, January 23, 2012 2:15 AM
Hi Jignesh,
have you solved this issue? I'd like to mark answers for this thread. If you have any questions or do not agree, you can post back and unmark them. We'll continue working with you on this issue.
Thanks for your understanding.
Best regards,
Helen Zhao [MSFT]
MSDN Community Support | Feedback to us
Thursday, January 26, 2012 9:15 AM
Hi Helen,
Sorry for delay !!!! Yes it is working fine.
I caught it using dependency Waker.
The cause is we are using EnumProcess.. API and OpenProcess of psapi.lib and this is causing problem.
Guys Thank you so much for all your answers.
See you soon :-)
Regards,
Jignesh
Jignesh