Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 646
John Smith Avatar asked May 30 '12 19:05

John Smith


People also ask

Can a 32-bit program call a 64-bit DLL?

Additionally, a 32-bit process cannot load a 64-bit DLL. However, 64-bit Windows supports remote procedure calls (RPC) between 64-bit and 32-bit processes (both on the same computer and across computers).

Does the 32bit applications run in a 64bit architecture of the computer Why or why not?

Most programs made for the 32-bit version of Windows will work on the 64-bit version of Windows except for most Antivirus programs. Device drivers that are made for the 32-bit version of Windows will not work correctly on a computer running a 64-bit version of Windows.

Can 64-bit Java load 32-bit DLL?

On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL.

What is 32bit and 64bit application?

A 32-bit system has a limit of 32 bit Windows 3.2 GB of RAM. The limit in its addressable space doesn't allow you to use the entire physical memory space of 4GB. A 64-bit system enables its users to store up to 17 Billion GB of RAM.


2 Answers

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.

like image 134
Roger Lipscombe Avatar answered Oct 20 '22 02:10

Roger Lipscombe


You could used WCF through a named pipe.

There is a simple example here: http://msdn.microsoft.com/en-us/library/system.servicemodel.netnamedpipebinding.aspx

like image 21
dmo Avatar answered Oct 20 '22 02:10

dmo