I recently had some challenges calling 32-bit DLLs from a third party from a ASP.NET Web Application via COM+ on a 64-bit machine running Windows Server 2008. The 3rd party DLLs also required an ODBC connection to the database.
Issue 1 - Exception: Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154.
I'd registered the DLLs in Windows\sysWOW64 using the version of regsrv32 in that folder.
Calls to the third party DLL worked from unit tests in Visual Studio but failed from the Web Application hosted in IIS on the same machine with the 80040154 error.
Changing the application pool to "Enable 32-Bit Applications" ([enable32BitAppOnWin64]) resolved the issue.
Issue 2 - The ODBC connection was not available
I'd created the ODBC connectino using %SystemRoot%\system32\odbcad32.exe. Again, this worked fine for the VS unit tests but fell over when run from IIS.
Using odbccad32.exe from the sysWOW32 folder to create the ODBC connection resolved the issue.
Issue 3 - Calling the 32-bit COM class from the WCFTestClient.exe resulted in the 80040154 (Class not registered) exception again
Wcftestclient.exe
will need to be flagged to run in as 32-bit by using the CorFlags.exe tool. E.g.
corflags.exe /32BIT+ wcftestclient.exe
See also: