如何在两个或多个程序之间共享内存中的System.Object?

发布于 2024-08-14 21:11:44 字数 136 浏览 2 评论 0原文

是否有任何库、代码示例、开源项目等可以帮助我在两个或多个具有直接或间接内存访问的程序之间共享对象(数据集、集合等)。
如果没有办法做到这一点,请告诉我其他方法让我的应用程序运行。

语言:c# .net
平台:vista x64

is there any library, code sample, open source project, etc helping me share objects(a dataset , a collection, ...) between two or more programs with direct or indirect memory access.
if there is no way to do that, please show me other ways to make my app work.

language:c# .net
platform:vista x64

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

听风念你 2024-08-21 21:11:44

您需要查看 WCF - Microsoft 的整合 Web 服务和远程处理框架。它为进程间通信提供了许多选项,从通过 http 的 XML 到通过 TCP/IP 或命名管道的二进制。

其他一些文章:

You want to look at WCF - Microsoft's consolidated WebServices and Remoting framework. It provides a number of options for inter process communication, from XML over http to binary over TCP/IP or Named Pipes.

Some further articles:

幽梦紫曦~ 2024-08-21 21:11:44

我相信您最好和最安全的选择是查看 Named通过 WCF 进行管道。直接来自 MSDN:

命名管道是一个对象
Windows操作系统内核,如
作为共享内存的一部分
进程可用于通信。一个
命名管道有一个名字,并且可以使用
用于单向或双工通信
在一台机器上的进程之间。

I believe your best and safest bet would be to check out Named Pipes via WCF. Straight from MSDN:

A named pipe is an object in the
Windows operating system kernel, such
as a section of shared memory that
processes can use for communication. A
named pipe has a name, and can be used
for one-way or duplex communication
between processes on a single machine.

倾城花音 2024-08-21 21:11:44

我不太确定如何可以实现这一点,但如果程序集都在同一域中,则可能是可能的。如果其中一个程序集加载另一个程序集并为其提供一个指针/引用,第二个程序集可以通过该指针/引用调用第一个程序集,则可以使用参数调用第一个程序集内的方法。

在我的一个用 C# 编写的 COM 插件项目中,COM dll 从程序集中实例化两个不同的类,并且它们可以共享静态数据。

I am not very sure about how this can be accomplished but It might be possible if the assemblies are both in same domain. If one of the assembly loads the other assembly and gives it a pointer/reference to through which the second assembly can call into the first one then it might be possible to call a method inside the first assembly with parameters.

In one of my projects which is a COM addin written in C#, a COM dll instantiates two different classes from an assembly and they can share static data.

分开我的手 2024-08-21 21:11:44

我不知道,所以我会让其他人来回答。如果不可能,并且根据两个应用程序是否需要实时了解更改,您可能会将类序列化到文件(例如 XML)以共享当前状态信息。

I'm not aware of any so I'll leave someone else to answer. If it's not possible, and depending on whether both applications need to be aware of changes in real time you could potentially serialize your class to a file (e.g. XML) to share the current state information.

菊凝晚露 2024-08-21 21:11:44

你可以以某种方式使用文件或数据库或任何其他持久技术、消息传递、WCF(或较低的进程间通信协议),如果

没有特殊的技巧,你通常无法从一个程序内存地址空间访问另一个程序内存地址空间,在 C# 中绝对不行。

you can use a file in a certain way or a database or any other persistent technology, messaging, WCF (or lower interprocess communication protocols)

you generally can't access one program memory address space from another without special hacks, definitely not in c#.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文