[ACCEPTED]-Access x86 COM from x64 .NET-64-bit

Accepted answer
Score: 31

If a component is running x64-native, it 23 can't load a 32-bit COM server in-process, because 22 it's the wrong sort of process. There are 21 a couple of solutions possible:

  1. If you can, build 20 a 64-bit version of the COM code (which 19 would of course register itself in the 64-bit 18 registry). This is the cleanest solution, but 17 may not be possible if you don't have the 16 code for the COM server.

  2. Run your .NET component 15 as 32-bit x86, instead of x64. I assume 14 you've already considered and rejected this 13 one for some reason.

  3. Host the COM component 12 out-of-process using the COM surrogate DLLhost.exe. This 11 will make calls to the COM server much, much 10 slower (they will now be interprocess Windows 9 messages instead of native function calls), but 8 is otherwise transparent (you don't have 7 to do anything special).

    This probably won't 6 be an option if the server requires a custom 5 proxy-stub instead of using the normal oleaut32 4 one (very rare, though), since there won't 3 be a 64-bit version of the proxy available. As 2 long as it can use the ordinary OLE marshalling, you 1 can just register it for surrogate activation.

Score: 7

I have found this solution, Dealing with Legacy 32-bit Components in 64-bit Windows see in article 4 :
• Converting a project type from in-process 3 to out-of-process
• Using COM+ as a host 2 (this work for me)
• Using dllhost as a 1 surrogate host

Score: 2

It's your COM component is housed in a COM 13 server (ie a seperate process) then you 12 won't need to do anything special as the 11 COM subsystem will remote your calls from 10 your x64 app to the X86 app and back again.

If 9 your component is an in-process COM component 8 then you'll have to rethink things as a 7 64 bit process can't use 32 bit in process 6 COM components. You could force your server 5 to run under x86 so that you can access 4 the components (they'll both be 32 bit processes). If 3 you don't want to do this then you'll have 2 to see if there a x64 bit version of the 1 COM components you're using.

More Related questions