Static Crossover

  • Thread starter Thread starter John A. Bailo
  • Start date Start date
J

John A. Bailo

I wrote two windows services that are slight variations on each other.

I changed the assembly name ( .exe ) and the namespace within each other.

Both have some static methods that share the same name.


I am seeing some evidence that there may be memory crossover -- where
one assembly is accesing resources defined in a same named method of the
other.


Is that possible? Are static members shared across namespaces?
 
John,

Short form, no, it is not possible.

When you have a static member in two different namespaces, that means
that they are each attached to two different types. Even if the types are
the same name, code, etc, etc, if the namespaces are different, then they
are two different types. The static fields for one are not going to be the
same as the static fields for another.

Additionally, the CLR makes sure that the scope of static fields is the
app domain you are running in, of which there can be multiple ones in a
process. That leads us to the fact that static field values are not shared
among the same type in separate processes.

Hope this helps.
 
Thanks!

False alarm anyway, I was referencing the same filename for logging in
two of the supporting classes so it looked like crossover, but it wasn't.
 
Back
Top