0

I have a solution which contains many separate EXEs that need to be able to send messages back and forth to one another. Right now each EXE has to know about each other up front and they use IPC to communicate but I really want a more elegant solution.

I want a factory where each EXE can register itself as an endpoint and any EXE can go to the factory and retrieve a list of all registered endpoints so he can send targeted messages to just the applications he needs to talk to at that time, without having to know before hand all the details about all the processes that talk.

I've got the factory DLL worked out but I don't know how to make it a global instance, one instance of the factory that is shared amongst all the running EXEs in the solution. I've been told to use WCF via an NT Service, Global Assembly Cache, and even told to maintain an XML file containing serialized endpoints in the allUsers AppData. I haven't investigated these options yet but I plan to start researching them in the next few days.

I'm wondering if anyone here can recommend a simple, elegant, and common-sense suggestion for accomplishing what I need to do (share a single instance factory among many running processes)

Neal Bailey
  • 183
  • 10

1 Answers1

1

The DLL itself is loaded into each EXE's address space. However you can declare a shared memory block in the DLL, or use Memory-Mapped files directly using Windows API. This way you get a block of memory which can be accessed from several EXEs (or from the same DLL loaded into several EXEs) at the same time. You will need a mutex to prevent concurrent writing to the memory block. That's all.

And forget about WCF and other complicated stuff for your task - people who gave those advices usually don't know much about IPC and system APIs and recommend the only things they know.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121
  • Thank you sir. I'm digging into the kernel32.dll::OpenFileMapping, CreateFileMapping, MapViewOfFile, etc, etc now. – Neal Bailey Feb 21 '13 at 18:08