LoadLibrary project.dll failed. The specified module could not be found
Asked Answered
L

3

9

When I try to register the 32 bit version of my C++ / ATL project with

regsvr32 project.dll

i'm getting this error:

LoadLibrary("project.dll") failed - The specified module could not be found

project.dll is my dll built using ATL on Visual Studio 10.

The 64 bit version registered fine.

What am I missing?

Ledet answered 30/7, 2012 at 7:46 Comment(3)
where is project.dll? in the same dir as where you invoke this command? in the PATH?Tevis
yes it's in the same directory (otherwise I would get an error saying that no such file exists!)Ledet
then open the dll in dependency walker and see what dlls are missingTevis
P
9

I have observed this exact same error, but the solution was not installing the redistributable. All the dependent DLLs were present on the system1 according to depends.exe.

In my case, the icon of KERNEL32.DLL was slightly red tinted. Depends.exe did not offer much explanation, but digging around revealed that one of the imported functions were missing from the DLL on the system. To see the imported functions, select the dependent DLL in the treeview and look for the import on the right panel. Order by the PI column to see the red icons of missing imports.

Seeing the missing import

In my case, the missing function was a function that did not exist on my sad target operating system, Windows XP. Since my program did not directly depend on this function, I was able to get away with #defineing the following in my project:

#define WINVER 0x0501
#define _WIN32_WINNT 0x0501

Compiling with these macros made it so the function in question was not declared in the headers, and consequently not imported at load-time. Now I was able to use regsvr32. This of course is a very specific (and lucky) case. I did not depend on that import or any other newer APIs, so I could get away with retargeting the project. Were it not a system DLL, I would have needed to find a newer version which could easily lead to a need to update a whole sub-tree of the dependency graph. Or even worse, if I depended on the missing imports, some serious refactoring would be needed.

To sum it up, this error message2 can be caused by the following issues:

  1. The DLL file was not found or could not be read. Check the command line.
  2. Some dependent DLLs were not found or could not be read.
  3. Some imports are missing from some dependent DLLs. If these are system DLLs, you are likely targeting a wrong version of Windows. If these are non-system DLLs, you need to install newer versions of them and all their dependencies.

1.: Apart from IESHIMS.DLL and WER.DLL which is apparently a bug in this old tool.
2.: Or really, any problems in loading the DLLs on a particular system

Panama answered 30/9, 2014 at 8:28 Comment(1)
Although I'm not working on that project anymore and don't have the ability to check this out, this does seem to be the correct way to approach this problem. +1 - Thanks!Ledet
E
5

The error description is misleading in this case. The system finds your DLL (project.dll) but one (or more) dependency of your DLL might be missing.

Eared answered 30/7, 2012 at 7:59 Comment(5)
Inspect your (32bit version) of your DLL with Dependency walker (dependencywalker.com) might helpEared
I tried this, and it showed that some dlls were missing, but when I downloaded these dlls and added them to the same directory as the project dll - each time directory walker found a new set of dlls missingLedet
As a matter of fact, some images have sub-dependencies! All static dependencies (direct and indirect) must be resolved before the Windows loader can start (in your case register) an application.Eared
Which DLLs are missing? You could have posted a screenshot onto the original question.Byrle
My development environment was masking a dll from getting found. Running it from Windows Explorer it was able to find the rest of the dependencies.Fields
L
2

I just installed

Microsoft Visual C++ 2010 Redistributable Package 

and now I can install the dll.

Although this works, I'm not too happy with this, because I don't want to have to install this package on a client in order for my dll to work by them.

Ledet answered 30/7, 2012 at 9:1 Comment(1)
I just noticed that in the installer that i'm using there's an option to include this package as a prerequisite - so the installer will go and download the package if the user doesn't already have it installedLedet

© 2022 - 2024 — McMap. All rights reserved.