I want to open up an existing instance if my program is already running only if its running the same version. I noticed that this question was asked for only if the name exists, but what if the version is older, I just want to notify the user that an older version is still running, “please remove older version before starting this version.”
The other link is this one:
Return to an already open application when a user tries to open a new instance but they don’t talk about closing an instance if an older or newer version is detected.
You can use a variant of the method which I describe here and that described here using System.Threading.Mutex.
I guess you could have two mutex’s. Mutex A named by a GUID and mutex B named by GUID and version number.
Your new instance can first check for mutex A on start up. If mutex A does not exist, then no other version is running. If mutex A exists then some other version is running.
The new instance can then check for existence of mutex B, using it’s own version number. If B does exist, then the other instance is the same version as the new instance, if B doesn’t exist, then some other version is running.