4

I know I read all about surrogate process, and I was able to create a surrogate COM but it either all works in 32bit or all works in 64bit.

What would be the correct structure?

1) 32.dll <- 64.com <- 64.exe 2) 32.dll <- 32.com <- 64.exe

I tried both of the above but I did not succeed to call the 32.dll?

casperOne
  • 73,706
  • 19
  • 184
  • 253
  • See [this answer](http://stackoverflow.com/a/12938217/184528) for a more comprehensive list of techniques for accessing 32-bit DLLs from 64-bit applications. – cdiggins Oct 17 '12 at 15:50

2 Answers2

1

I'm not too informed about the surrogate COM you refer to but I've solved this problem (Using a 32bit dll from a 64bit exe) by introducing a COM object in the middle:

32.dll <-> 32bit-out-of-process-com-server.exe <-> 64.exe.

Sorry this might be what you mean by 32.com, not sure, but make sure the intermediate COM object lives in an .exe (out of process) and not in a dll. This is for the same reason you can't load the original 32.dll into the 64 bit process.

Hannes de Jager
  • 2,903
  • 6
  • 37
  • 57
  • 1
    That's called an out-proc COM server - you wrote a separate .exe yourself. That's a good solution, but requires some effort. The OP is asking about a slightly different thing - when with some tweaks COM runtime creates a special process (called surrogate) and loads the .dll there and then it all works as if there was an out-proc COM server in the first place. – sharptooth Nov 09 '10 at 13:51
  • Very neat. Thank you for taking the time sharptooth! – Hannes de Jager Nov 09 '10 at 20:00
0

This is defenetly what you want: 32.dll <- 32.com <- 64.exe If it does not work, show more details HOW it does not work.

Also, if you are not doing much calls, you may communicate via sockets (just a backup plan).

BarsMonster
  • 6,483
  • 2
  • 34
  • 47
  • actually I am only calling one function passing a filename but the dll has to be hosted by an application domain because it creates a window and wait for a user response. – Canan Erdol Sep 23 '10 at 13:58
  • what did you mean by socket calls. For example, create a com that listens to a port and when connected fire up the 32.dll? Maybe I could to that with a service? – Canan Erdol Sep 23 '10 at 14:00
  • The actuall problem with 32.dll <- 32.com <- 64.exe is that when I create the com object in the 64.exe it can not find it because it is registered as 32.com, somehow the WOW divert it as an error: unregistsred class. – Canan Erdol Sep 23 '10 at 14:07
  • Yes, 32bit app listens a port, and executes commands from it. You send commands from 64bit app. This will work at all times :-) – BarsMonster Sep 24 '10 at 07:16