I don't think it can help you to tell the difference between those instances. Even if you could change the assembly description, before doing that you would need to know is this a first instance of not, so you would need to communication to other instance(s) anyway.
First, understand this: the instances of the same application are completely different processes, isolated from each other exactly as well as any other different processes. Also, understand that an assembly is not a process. An assembly consists of executable modules (VS can create only one), and a process can be started from the name of a main executable module of any assembly. So, the conclusion is: what you need is communication between different processes, and this is called IPC.
There are a number of different methods using to tell the different processes of the same application apart. One simple method is using
System.Diagnostics.Process.GetProcesses
, see
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[
^].
A process can look at the already running processes and see if one or more instances of the same application is already running. You need to be careful: a completely different application can have the same name, a title of the main window, etc. You can compare them by the name of main executable module. In this case you won't be able to identify the "same" application which was copies (as a set of executable files) to other directory. This problem really does not have a solution, simply because the definition of "same application" does not even exist. I would consider the application to be the "same" if it was started from the same main executable module (found for a currently running code as
System.Reflection.Assembly.GetEntryAssembly().Location
).
If you simply need to develop a single-instance policy, one of the very best .NET methods is using classic remoting. An application should act as a service part. Before doing that, and application should try to connect to an existing server. It it is successful, the application runs in a second instance and should be terminated pretty soon. An exception in connection means that there is no a service part, so the currently running application is the first instance and it should act as a server. As (or if) all instances run on the same machine, you need to use IPC channel (the one based on named pipes). For the name of the channel, you can use the same thing: a name of the main executable module; which is guaranteed to be unique in the local system.
You can use the same kind of IPC in more general cases. Another means of IPC include shared memory block, self-hosted WCF, named Mutex, etc.
—SA