Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154

In VS - project properties - in the Build tab - platform target =X86


I ran into a very similar issue.

I needed to use an old 32-bit DLL within a Web Application that was being developed on a 64-bit machine. I registered the 32-bit DLL into the windows\sysWOW64 folder 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" resolved the issue.


It sounds like your service was built against 'Any CPU', causing you errors on 64-bit where you are using COM components. You need to build it for x86.

The website is probably running as a 32-bit process which is why it can use the component. Building your solution against x86 will force your service to run as 32-bit.


You dont have to configure your project properties platform target X86. You can also configure the iis options to work with x86 like that

  • Select Application pool
  • Select the pool which your app uses
  • Advanced settings
  • Enable 32 bit applications true

If you are looking for a way to make this work without recompiling your Any CPU application, here is another potential workaround:

  1. Locate your COM object GUID under the HKey_Classes_Root\Wow6432Node\CLSID\{GUID}
  2. Once located add a new REG_SZ (string) Value. Name should be AppID and data should be the same COM object GUID you have just searched for
  3. Add a new key under HKey_Classes_Root\Wow6432Node\AppID. The new key should be called the same as the COM object GUID.
  4. Under the new key you just added, add a new String Value, and call it DllSurrogate. Leave the value empty.
  5. Create a new Key under HKey_Local_Machine\Software\Classes\AppID\ Again the new key should be called the same as the COM object’s GUID. No values are necessary to be added under this key.

I take no credit for the solution, but it worked for us. Check the source link for more information and other comments.

Source: https://techtalk.gfi.com/32bit-object-64bit-environment/