c++ – 32 Bit Com Server on 64 Bit System – Education Career Blog

i developed a Com Server and on windows XP 32 bit. To Test the Com Server i created a Client with C# to call the Functions via Interop.
Everything works fine, but now i need to get the ComServer run on a Windows 7 64 bit System.
I took the ComServer DLL and the C# EXE to the 64 bit Computer, registered the ComServer DLL with regsrv32 and started the C# Program.
Wen i first tried to access a ComServer Function all i get is the Error:

System.Runtime.InteropServices.COMException (0x80040154): Die COM-Klassenfactory für die Komponente mit CLSID {BA4D7F46-A47E-4CB9-A153-2B4657C4DD29} konnte aufgrund des folgenden Fehlers nicht abgerufen werden: 80040154.

in English:

System.Runtime.InteropServices.COMException (0x80040154): The COM-Classfactory for the Component with the CLSID {BA4D7F46-A47E-4CB9-A153-2B4657C4DD29} was not able to be called due to the Error: 80040154.

Whhat is going wrong here? Isn’t it possible to call a 32 Bit DLL on a 64 Bit System? If yes, how do all the other 32 bit Programs work?



You can’t load a 32-bit library into a 64-bit process and vice versa – the library and the process must be of same bitness.

The best solution is to get a 64-bit version of the COM server library. If that is not possible (which is quite usual) you have two options:

  • make the consuming program 32 bit (likely you have to change the target from “Any CPU” to “x86” in Visual Studio)
  • force the COM server into a surrogate process (use COM+ for that).

In the first case you make both the program and the COM server 32 bit and so the COM server library loads fine. In the second case COM+ creates a 32-bit surrogate process and loads the library into it, your program communicates to that process via RPC, so you don’t care of bitness difference.

Both options have drawbacks. In the first case you make your program 32 bit even on 64-bit systems. In the second cas eyou encounter overhead due to the interprocess communications.


From here :

Use corflags with the /32bit+ switch to get the app to run in 32 bit mode

CorFlags.exe assembly options

Leave a Comment