views:

362

answers:

0

I have a custom WCF ServiceHost that opens a persistent object to an external resource. The operations on the contract are then wired on to this persistent object. The persistent object manages itself to ensure it's always in a usable state.

I'm having a difficult time deciding where it is safe to dispose this object -- because once it's gone the ServiceHost is trash. With app pool recycling and iisreset I just need to ensure that only one of these objects exists while the w3wp is running.

Are there cases where IIS will have more than one ServiceHost instantiated? Any insight as to how IIS manages ServiceHosts?

I'm thinking about using IRegisteredObject.Stop(bool), but before I go that route I just wanted to get some input.