Retrieving COM class factory failed due to the following error: 80040154

When installing a new version of Windows 7 (64 bit), I came across this error when attempting to run one of my web services:

Retrieving COM class factory failed due to the following error: 80040154

No real explaination on what component was causing the problem, but stepping into the code, there is a dependency on a third party COM DLL to communicate with a remote server. The COM component is 32 bit - getting it to run in the 64 bit environment is the issue.

Changing the build in VS to x86 did not correct the problem, the component still failed to load.

Since the component is hosted in IIS, IIS needs to be told to run in 32 bit mode instead of 64. There are a few links on the web that state that IIS 7 must be set to run in 32 bit mode to support this and this is at the expense of all your other applications, however, this is not the case.

The better way to support this is to setup a dedicated application pool to run in 32 bit mode and set the web application to use this application pool, allowing you can continue to use IIS 7 in 64 bit mode for your other applications. This application pool will now run in WOW64 (Windows on Windows 64) mode which runs in 32 bit mode and as such will only load 32 bit applications, so if you also have another 64 bit dependency you will need to run that in a different application pool and invoke it through another web application.

Enjoy!

Posted in Development | Tagged , , , , , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre user="" computer="" escaped="">