简体   繁体   中英

C# Sharing instances between apps

I have two C# apps. The first one creates an instance of an object, sets some properties, etc.

The second app needs to get access to this instance with its set properties etc.

Is there a way I can do this. Perhaps storing the instance inside the operating system or something like that?

I've found that I can persist an object, but the first app is creating a connection to a low level interface which takes some time to connect. I want to keep that connection open and have other apps use it.

You need some means of inter-process communication . Back in the "old days", this was done with .NET remoting, but the technology has been deprecated.

The .NET technology currently recommended by Microsoft for inter-process communication is the Windows Communication Foundation (WCF) . Yes, some might argue that this is overkill for simple object sharing, but that's the currently supported and recommended technology for this purpose.

A high-level overview of WCF and other options can be found in the following MSDN article:

You cannot do this as described. No two applications can share memory across application bounds. Instead, when you pass objects from one to the other, they are serialized, and if you need one or the other to respond to changes, you should look into event callbacks or the like. I recommend looking into WCF services for this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM