0

I need to create a common (GAC) assembly which hosts a singleton object. This singleton assembly would be registered in GAC and multiple applications need to refer this. Assembly should be sharing the exact state across all these applications.

What happens presently is that:

  1. Suppose my first application i.e application1 referring to singleton have an object which remains as singleton within that application scope
  2. when second application refers singleton, the old state for application 1 is not shared and its a new instance. What I need is that instance for application1 should be shared with application2
piet.t
  • 11,718
  • 21
  • 43
  • 52
  • 1
    Every applicaiton have it own domain ...and because of that you will have singleton object for each application ..... – Pranay Rana Nov 30 '17 at 12:52
  • How do you expect that an application to load the state from another application? The Singleton will exist on the context of the calling application. You need to put that Singleton in an application and call that application if you want to share the memory – Camilo Terevinto Nov 30 '17 at 12:52
  • The GAC should not be considered to be something like the ROT in COM –  Nov 30 '17 at 12:55
  • 2
    There is no way to do this just by assembly or app domain instances, nor can you share generic .NET objects across processes (you can use shared memory, but that's raw bytes). Whatever data you want to share should be in its own service, which then processes calls from other applications. The closest thing there is to "native" object sharing this way is .NET remoting, which is mostly but not completely transparent. The most appropriate solution depends heavily on what kind of data you're sharing and whether it should survive process restarts. – Jeroen Mostert Nov 30 '17 at 12:56

0 Answers0