Newbie: static objects across different processes are shared?

  • Thread starter Thread starter Fabio Cannizzo
  • Start date Start date
F

Fabio Cannizzo

My assembly contains some static objects, e.g.

public myClass {
static int i = 0;
}

If the DLL is loaded by two processes, do these share the instance of "i"?
What if the DLL is in the GAC?

Thanks,
Fabio
 
The question reminds me singleton pattern. Singleton pattern is valid for
the same process threads. If u need to achieve this over processes, u need
to apply a service oriented approach. INMH, it is not important DLL is in
the GAC or not. I think it depends processes.
 
Fabio Cannizzo said:
My assembly contains some static objects, e.g.

public myClass {
static int i = 0;
}

If the DLL is loaded by two processes, do these share the instance of "i"?
Nope.

What if the DLL is in the GAC?

Nope.

In fact, if you load the same assembly in different AppDomains even
within the same process, you'll have two different variables.
 
Back
Top