I have a class SystemConfig
on its own project and executable.
I have implemented a singleton for that class with a property called Instance
.
So my question is, when I reference this executable in a different project and use the same singleton instance (I.e., SystemConfig.Instance.GetConfig()
), would it be the same as the one when I run the SystemConfig
executable?
My answer is no but just making sure.
Not only will it not be the same if you're running a different executable - it will not be the same if you run the same executable twice as two separate processes.
Basically, your singleton is likely to only be a singleton for a single AppDomain
. (In most cases there's one AppDomain
per process you start, although some apps will use more.)
See more on this question at Stackoverflow