By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,608 Members | 1,925 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,608 IT Pros & Developers. It's quick & easy.

Shared variable problem

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <f5****************************@phx.gbl>,
an*******@discussions.microsoft.com says...
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.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #2

P: n/a
In article <f5****************************@phx.gbl>,
an*******@discussions.microsoft.com says...
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.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.