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

Windows does not allow a 32-bit process to load a 64-bit dll, so I'm trying to use remote access to allow a 32-bit process to interact with a 64-bit process.

Here's the problem: while two applications are located on the same computer, one of them is 32 bits and the other is 64 bits, and they should be like this: creating 32-bit or 64-bit files will break all these applications built on top .

I use the .NET class System.Runtime.Remoting.RemotingConfiguration and calling its Configure () method and passing a link to the App.config file that references the MarshalByRefObject class, which I will access through remote access.

I got it to work, but only until the Client, Host, MarshalByRefObject class is either 32-bit or 64-bit. If I mix them up, this will not work: in the end, I get a BadImageFormatException:

Failed to load file or assembly "MyRemotingObject" or one of its dependencies. An attempt was made to download a program with the wrong format.

The exception disappears as soon as I make both applications either 32-bit or 64-bit, but again, one of them should be 32-bit and the other 64-bit.

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

+6
source share
2 answers

Random assumption: for .NET remote access, you must load the assembly into both processes in order to obtain metadata. The contract for your data (to use the term WCF) must be in a separate assembly and must be compiled as "AnyCPU" so that it can be loaded into any process. You have explicitly installed 32-bit or 64-bit.

+8
source

You could use WCF through a named pipe.

Here's a simple example: http://msdn.microsoft.com/en-us/library/system.servicemodel.netnamedpipebinding.aspx

+3
source

Source: https://habr.com/ru/post/917045/


All Articles