I have here what would appear to be a simple task; listing all the instances of a service object actively managed by a WCF ServiceHost
at any particular time.
For example, my service contract interface is IFooService
and the implementation is FooService
(with a per-session behaviour). On the service side I simply instantiate the service host using ServiceHost(typeof(FooService))
and open it. Sessions are created, destroyed, and operations called as normal by clients - and for the most part, the fact that this functionality is hidden is good.
However, my goal is to expose a method in the class that declares the ServiceHost
that lists all currently active instances of IFooService
(or similarly FooService
). Having the class track its own instances is possible, but doesn't seem too elegant. Is there any in-built method for WCF to return a list of all service object instances managed by a ServiceHost
?