.net64-bitipcremoting32-bit

How can a 32 bit process communicate with a 64 bit process in .NET?


Windows does not make it possible for a 32 bit process to load a 64 bit dll, so I am trying to use remoting in order to allow the 32 bit process to interact with a 64 bit process.

Here's the problem: while the two applications are located on the same machine, one is 32 bit and the other is 64 bit, and they have to be that way: making both 32 bit or 64 bit would break everything these applications are built on top of.

I'm using .NET's System.Runtime.Remoting.RemotingConfiguration class and calling its Configure() method and passing a reference to an App.config file which references the MarshalByRefObject class that I'll be accessing via remoting.

I got it to work, but only as long Client, Host, MarshalByRefObject class are either 32 bit or 64 bit. If I mix them up this won't work: I'll end up with a BadImageFormatException:

Could not load file or assembly 'MyRemotingObject' or one of its dependencies. An attempt was made to load a program with an incorrect format.

The exception goes away as soon as I make both apps either 32 bit or 64 bit, but again, one of them must be 32 bit and the other 64 bit.

Can someone tell me how to enable interprocess communication between a 32 bit .NET app and a .64 bit .NET app?


Solution

  • Random guess: .NET remoting needs to load the assembly into both processes to get hold of the metadata. Your data contract (to use the WCF term) should be in a separate assembly and should be compiled as "AnyCPU", so that it can be loaded into either process. You've got it explicitly set to 32-bit or 64-bit.