Tuesday, July 10, 2012

VB6 DLL Failed to Load on Windows x64

I ran into a problem today that I struggled with for a couple of hours. I just had my machine upgraded from a Windows XP x86 (32 bit) to a Windows 7 x64 machine. We have some legacy custom applications that require a VB6 dll to be registered. Everytime I ran the regsrv32 command on the DLL to register it, I got the below error:


The module "MyVB6.dll" failed to load.

Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files.

The specified module could not be found.

I found posts that talk about making sure I run the command with adminstrator rights but it didn't help. I finally found the below URL:

http://social.msdn.microsoft.com/Forums/en-US/sbappdev/thread/91cf3127-70fe-4726-8a27-31b8964430c5/

It says that I need to make sure that the DLL does not sit in the System32 folder like we did on WinXP. Because the DLL is a 32 bit DLL, you need to use the 32 bit version of regsvr32 and that is in the SysWOW64. I even tried to run the command from SysWOW64 but leave the DLL in System32 and still got the same error. The DLL must sit in the SysWOW64 folder and be registered by the regsvr32.exe in the SysWOW64 folder.