如何在两个或多个程序之间共享内存中的System.Object?
是否有任何库、代码示例、开源项目等可以帮助我在两个或多个具有直接或间接内存访问的程序之间共享对象(数据集、集合等)。
如果没有办法做到这一点,请告诉我其他方法让我的应用程序运行。
语言: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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您需要查看 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:
我相信您最好和最安全的选择是查看 Named通过 WCF 进行管道。直接来自 MSDN:
I believe your best and safest bet would be to check out Named Pipes via WCF. Straight from MSDN:
我不太确定如何可以实现这一点,但如果程序集都在同一域中,则可能是可能的。如果其中一个程序集加载另一个程序集并为其提供一个指针/引用,第二个程序集可以通过该指针/引用调用第一个程序集,则可以使用参数调用第一个程序集内的方法。
在我的一个用 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.
我不知道,所以我会让其他人来回答。如果不可能,并且根据两个应用程序是否需要实时了解更改,您可能会将类序列化到文件(例如 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.
你可以以某种方式使用文件或数据库或任何其他持久技术、消息传递、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#.