See the question and my original answer on StackOverflow

The 0x80040154 aka REGDB_E_CLASSNOTREG or "Class not registered" error usually means ... well, that the class is ... not registered. But the exact reason can be a bit complex.

COM clients and COM servers that run both in-process need to run with the same bitness, so both in x86 or both in x64. So:

  • If a COM client runs as x86, it talks to the x86 side of the registry, so the COM server must registered in the x86 side of the registry (regsvr32, regasm, custom reg code, etc. must run as x86).

  • If a COM client runs as x64, it talks to the x64 side of the registry, so the COM server must registered in the x64 side of the registry (regsvr32, regasm, custom reg code, etc. must run as x64).

Note 1: for out-of-process communications x86 clients or servers can talk to x64 servers or clients. That's one benefit of COM.

Note 2: the .NET "Any CPU" compilation feature allows to use the exact same binary for x86 and x64 but this binary still needs to be registered in the needed registry side, or in both registry sides if x86 clients and x64 clients support is needed.