Strange LoadLibrary Bug??

Started by
9 comments, last by CrazyCdn 16 years, 9 months ago
I'm using the LoadLibrary call in a VC++ app. The app works fine on a XP machine. However, the minute I run on a XP Pro machine, the dll is not loaded and I exit out. I did the obvious check and made sure my dll was present. It is in the same folder as my .exe. According to the documentation, the dll is searched for in this directory 1st. I've run the app on a fresh, newly installed XP system just fine. It simply won't load the dll in XP Pro. I checked and I'm logged in as System admin on the XP Pro machine. Do I need to do something special when in XP Pro? Thanks for any help.
Advertisement
I doubt it has anything to do with XP vs XP Pro. More than likely it's just a difference between your two machines.

Does your dll have dependencies on other dlls (e.g. the MSVC dlls) that might not be present on the XP Pro machine? If so, it won't load.
Using Sysinternals Filemon, you could check where exactly the application tries to locate the dll.
Maybe, the working directory of your application is set to a different folder on the XP Pro machine.
Yes, I thought that might be a problem. I've run the app on several, non-developer XP machines and the app works fine. If it is another dependency, it is not related to the development studio. Thanks for the input.
I've tried explicitly naming the path (and made sure both systems were copied to same paths) and got the same results, OK on XP, not OK for XP Pro. The tool looks cool though. I'll give it a try.
Dependency walker is your friend.
Phil_T, you were absolutely right! I found another XP Pro machine and it worked. The XP Pro machine that I 1st tested on was a fresh system (only the OS was loaded). I've done all the Windows Updates and it still does not work. It must be some obsecure dependency that I just can't see. Thanks Wack for the tool. I'll give it try now. Hope it works!
Solved! Using the dll dependency tools, I went down the list and found the missing dll. It was mfc71.dll! I thought this dll was standard !?! I searched on several non-developer PC's and found the the dll just fine. I'm glad I it worked after copying the missing dll. However, I'm curious why it was missing in the 1st place. I went as far as re-intalling the OS for the machine. However, I was forced to use the recovery CD that came w/ the machine. Can anyone help me w/ this part of the mystery?
mfc71.dll is only included with MSVC, not with Windows.

Go into your project properties and set "Use of MFC" to "Use MFC in a Static Library" (that's what it's called in MSVC2003 anyway) and the problem should go away...
You are right. Why was I able to find it on numerous non-developer PC's (PC's w/out Visual Studio or anything of the sort)? I got a fresh laptop from the IT deparatment that was going to be used by the accounting staff? Could some other software package be loading the dll? I took a quick look at the accounting staff's laptop and could only see MS Office & Outlook. You were right about the static setting. The dll was built w/ the shared flag set ON.

This topic is closed to new replies.

Advertisement