Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Static constructor, App Domain, Remoting issue

Status
Not open for further replies.

mrscary

Programmer
Mar 7, 2003
151
GB
Here is the problem.

I have two app domains - one of which hosts class A - shall we say, and the other class B.

Now - class B has a static constructor that takes a while to initialise all the data - keeping the data in readonly static member data. This object is remoted - such that when the class is called it is instanced and it runs in AppDomain B - this is fine. So far so good.

However, also - when it is remoted for the first time, the static CTor gets called from the calling domain as well - in effect the static CTor gets called once from each domain that calls it - and then once in the domain where the object actually exists.

As the object only exists in one app domain - and everywhere else is just a proxy - I only want the static ctor being called once.

Any ideas?

M.

Hollingside Technologies, Making Technology work for you.
 
I think this is by design -- The static content of a class needs to be kept somewhere, and it looks like it's kept at the AppDomain level.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Hmm - yes kinda.
On further investigation - if you have a static constructor for an object -it appears that it will get called twice. Once in the app domain in which the object resides, and once again in the app domain in which the object is called from.

M.

Hollingside Technologies, Making Technology work for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top