Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Register DLL file on Windows Server 2008 R2

Tags:

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

like image 371
Broken Link Avatar asked Dec 28 '10 23:12

Broken Link


People also ask

How do I manually register a DLL?

Click Start > All Programs > Accessories and right-click on "Command Prompt" and select "Run as Administrator" OR in the Search box, type CMD and when cmd.exe appears in your results, right-click on cmd.exe and select "Run as administrator" At the command prompt, enter: REGSVR32 "PATH TO THE DLL FILE"

How do I make sure a DLL is registered?

Enter the "regsvr" command and the DLL's name. Type in regsvr32 and type a space, then type in your DLL's name (complete with the ". dll" extension) and press ↵ Enter . If your DLL can be registered, doing this will result in a confirmation message.

How do I register all DLL files in a folder?

For example, enter this command line if you want to open the system32 directory on drive C: cd C:\Windows\system32. finally, to register all the DLLs contained in the directory, type the following line on the same Command Prompt: FOR %1 IN (*. DLL) DO REGSVR32 /S %1.

How do I register with regsvr32?

Register 32 or 64-bit DLLs in Windows Step 1: First click on Start, then Run. Step 2: Now all you have to do to register a DLL file is to type in the regsvr32 command, followed by the path of the DLL file. Step 3: Now click OK and you should get a confirmation message that the DLL has been registered successfully.


2 Answers

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.

like image 93
Hans Passant Avatar answered Oct 16 '22 11:10

Hans Passant


You might need to register this DLL using the 32 bit version of regsvr32.exe:

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

like image 25
Kev Avatar answered Oct 16 '22 13:10

Kev