可以在同一个DLL的数据由2个不同的进程共享? [英] Can the same DLL data be shared by 2 different processes?

查看:721
本文介绍了可以在同一个DLL的数据由2个不同的进程共享?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在同一时间运行两个不同的C#应用​​程序。

I have two different C# applications that are running at the same time.

我想他们两个是能够访问的同一个实例 DLL(也是在C#)。

I would like both of them to be able to access the same "instance" of a DLL (also in C#).

该DLL包含一些数据,我想回到这两个应用程序的为准自讨苦吃。

The DLL holds some data that I'd like to return to whichever of the two applications is asking for it.

我的DLL是线程安全的,所以我希望这将是可能的,但我不知道怎么样。

My DLL is thread-safe so I was hoping this would be possible but I'm not sure how.

任何帮助或建议将不胜感激。

Any help or advice would be much appreciated.

推荐答案

的进程空间将是不同的,因此,例如,在DLL中的全局变量将是具体的每个单独的过程。可能的是在存储器中的代码将被共享(视窗通常使用的引用计数,使该部分更有效)。

The process space will be different so, for example, global variables in the DLL will be specific to each separate process. It is possible that the code in memory will be shared (Windows typically uses reference counting to make that part more efficient).

如果你想要共享该被访问信息在这两个过程之间的DLL中,然后它可能似乎有必要使用某种IPC(进程间通信)机制,如套接字,共享存储器,管等的

If you are wanting to share information that is accessed in the DLL between the two processes, then it seems likely that it will be necessary to use some kind of IPC (interprocess communication) mechanism such as sockets, shared memory, pipes, etc.

这篇关于可以在同一个DLL的数据由2个不同的进程共享?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆