Jelly Amma Jelly Amma - 1 year ago 86
C# Question

Can the same DLL data be shared by 2 different processes?

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

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

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

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.

Answer Source

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).

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.