Register DLL file on Windows Server 2008 R2

Broken Link picture Broken Link · Dec 29, 2010 · Viewed 147.2k times · Source

I'm trying to register a COM DLL file on Windows Server 2008 R2. Here are the steps I took:

  1. Run cmd as administrator
  2. c:\windows\system32\regsvr32.exe c:\tempdl\temp12.dll

When I execute that command I get this error:

The module temp12.dll failed to load. Make sure the binary is stored at the specified path or debut it to check for problems with the binary or dependent .DLL files. The specified module could not be found.

I was able to register the same DLL file on Windows 2000.

I also tried

c:\windows\syswow64\regsvr32 "c:\tempdl\temp12.dll"

And I got this error:

the module c:\tempdl\temp12.dll was loaded but the call to DllRegisterServer failed with error code 0x80040154. For more information about this problem, search online using the error code as the search term

Answer

Hans Passant picture Hans Passant · Jan 5, 2011

That's the error you get when the DLL itself requires another COM server to be registered first or has a dependency on another DLL that's not available. The Regsvr32.exe tool does very little, it calls LoadLibrary() to load the DLL that's passed in the command line argument. Then GetProcAddress() to find the DllRegisterServer() entry point in the DLL. And calls it to leave it up to the COM server to register itself.

What that code does is fairly unguessable. The diagnostic you got is however pretty self-evident from the error code, for some reason this COM server needs another one to be registered first. The error message is crappy, it doesn't tell you what other server it needs. A sad side-effect of the way COM error handling works.

To troubleshoot this, use SysInternals' ProcMon tool. It shows you what registry keys Regsvr32.exe (actually: the COM server) is opening to find the server. Look for accesses to the CLSID key. That gives you a hint what {guid} it is looking for. That still doesn't quite tell you the server DLL, you should compare the trace with one you get from a machine that works. The InprocServer32 key has the DLL path.