9

I'm working on my Window Application and i'm using some static members.

public class MyParameter
{
    public static string connectionString = "...";
}

Now if I install my application on computer and open two instance of same application. Will 'connectionString' common to the two instances?? Or every instance has its connectionString ?

Dennis Traub
  • 50,557
  • 7
  • 93
  • 108
dchamba
  • 115
  • 2
  • 7

3 Answers3

13

The variable static or not is a part of your application memory. When you open 2 instances of your application you create two distinct memory locations in the OS, so there is not any relation between those 2 variables at all.

If you want to create one (relation), you have to look on different IPC (Inter Process Communication) methods available in OS, like:

polfosol ఠ_ఠ
  • 1,840
  • 26
  • 41
Tigran
  • 61,654
  • 8
  • 86
  • 123
4

No, Each application instance are isolated from one another using AppDomain. Thus each application instance will run in a seperate AppDomain and cannot access the variables from other domain. To do communicate with different domain we need to use Remoting , WCF Service

Vimal CK
  • 3,543
  • 1
  • 26
  • 47
3

Every instance.

Static members are allocated on a per AppDomain basis. If you were to spawn a new AppDomain from within your current one.. they would be different.

Simon Whitehead
  • 63,300
  • 9
  • 114
  • 138