Shared variable problem

  • Thread starter Thread starter Ringo
  • Start date Start date
R

Ringo

I've just designed (or at least what I thought was) a
clever class with shared members and properties, great no
more having to pass an object to all of the other classes
that need it. The problem occured when I had to run
separate instances of my assembly in COM+. I discovered
that "shared" really means shared. I was using this class
to hold state information about the running assembly,
however when the second instance of the assembly started
executing , it overwrote the state information of the
first (because all instances are part of DLLHOST in
COM+). I thought I had a solution using the ThreadStatic
attribute but all that achieved was preventing the second
instance from executing.

Does anyone know I can restrict the scope of the shared
variables?

Thanks
Ringo
 
I've just designed (or at least what I thought was) a
clever class with shared members and properties, great no
more having to pass an object to all of the other classes
that need it. The problem occured when I had to run
separate instances of my assembly in COM+. I discovered
that "shared" really means shared. I was using this class
to hold state information about the running assembly,
however when the second instance of the assembly started
executing , it overwrote the state information of the
first (because all instances are part of DLLHOST in
COM+).

If you want the state information different for each, I think you'd want
to avoid shared (static) variables and go with instance variables.
Does anyone know I can restrict the scope of the shared
variables?

I don't think you can.
 
Back
Top