how to share a System.Object in memory between two or more programs?
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 indire开发者_如何学Pythonct 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 x64You 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:
- http://www.infoq.com/news/2008/01/wcf-comm-options
- http://en.wikipedia.org/wiki/Windows_Communication_Foundation
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.
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.
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.
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#.
精彩评论