4

What is the lifetime of an AppDomain in WCF?

Does it relate to InstanceContextMode, ConcurrencyMode and/or AspNetCompatibilityRequirements RequirementsMode?

I'm looking to know how long my static variables will be around and how often they'll have to be recreated.

SGarratt
  • 984
  • 1
  • 8
  • 22

1 Answers1

7

WCF doesn't actually control the app domain lifetime, the host does. If you're hosting in a Windows Service, then it's the lifetime of the service. If you're hosting in IIS it's the lifetime of the application pool which is subject to all sorts of recycling based on how its configured.

Drew Marsh
  • 33,111
  • 3
  • 82
  • 100
  • Thanks, that makes sense to me. In the IIS situation, if I have an InstanceContextMode of PerCall or PerSession, do I get one AppDomain which they all share? – SGarratt Apr 01 '12 at 17:41
  • They're all being instantiated in the same AppDomain, you're just getting isolation at the service instance level. So if you had a static in your service class, all instances would share that one static. – Drew Marsh Apr 01 '12 at 17:47
  • Thanks for the clarification. I've had a good search for this and even got Juval Lowy's book but he barely mentions AppDomains - hardly anyone did, at least in this context. – SGarratt Apr 01 '12 at 18:10