I wanted to create a WCF that employs a singleton pattern but the service itself would not share the same memory as other users?
my WCF ServiceBehavior currently is setup to this:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
Unfortunately, there are instances that data is mixed up to two different users (which is a bad thing).
I could do a PerCall, but i would modify a whole lot of code 🙁
Just hoping there is still chance for my code.
Singleton = any private field in the class are shared among all calls to the class. If you want to have singleton service but separate data for each user you must store the data elsewhere (not in the service instance) – for example in the database and load them for every user’s call.
Singleton service should be used in very rare cases. Most of the time usage of singleton service only means wrong architecture.