简体   繁体   English

32位进程如何与.NET中的64位进程通信?

[英]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. Windows无法使32位进程加载64位dll,因此我尝试使用远程处理以允许32位进程与64位进程交互。

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. 这就是问题所在:虽然两个应用程序位于同一台机器上,但一个是32位,另一个是64位,它们必须是这样的:32位或64位都会破坏这些应用程序构建在顶层的所有内容的。

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. 我正在使用.NET的System.Runtime.Remoting.RemotingConfiguration类并调用其Configure()方法并将引用传递给App.config文件,该文件引用我将通过远程处理访问的MarshalByRefObject类。

I got it to work, but only as long Client, Host, MarshalByRefObject class are either 32 bit or 64 bit. 我得到它的工作,但只有长,Client,Host,MarshalByRefObject类是32位或64位。 If I mix them up this won't work: I'll end up with a BadImageFormatException: 如果我把它们混合起来这将无效:我最终会遇到BadImageFormatException:

Could not load file or assembly 'MyRemotingObject' or one of its dependencies. 无法加载文件或程序集“MyRemotingObject”或其依赖项之一。 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. 只要我将这两个应用程序设置为32位或64位,异常就会消失,但同样,其中一个必须是32位,另一个必须是64位。

Can someone tell me how to enable interprocess communication between a 32 bit .NET app and a .64 bit .NET app? 有人能告诉我如何在32位.NET应用程序和.64位.NET应用程序之间启用进程间通信吗?

Random guess: .NET remoting needs to load the assembly into both processes to get hold of the metadata. 随机猜测:.NET远程处理需要将程序集加载到两个进程中以获取元数据。 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. 您的数据协定(使用WCF术语)应该在一个单独的程序集中,并且应该编译为“AnyCPU”,以便可以将其加载到任一进程中。 You've got it explicitly set to 32-bit or 64-bit. 您已将其明确设置为32位或64位。

You could used WCF through a named pipe. 您可以通过命名管道使用WCF。

There is a simple example here: http://msdn.microsoft.com/en-us/library/system.servicemodel.netnamedpipebinding.aspx 这里有一个简单的例子: http//msdn.microsoft.com/en-us/library/system.servicemodel.netnamedpipebinding.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM