I have a WCF service I use for configuration stuff hosted in a windows service that will be used to maintain a database. Is there any way that I can access the WCF service inside of the hosting service? Or should I move the database functionality to another WCF service and host them both inside of a windows service?
Share
The service class (the one implementing your service interface) has a property
which gives you access to the
ServiceHostinstance which is hosting your service. You can access that service host pretty easily.There’s no built-in way to reach beyond the service host and manipulate or query the NT service containing the service host. But you could always create your own custom ServiceHost descendant class which would give you the necessary access to the NT service itself, and then use that custom service host for your service implementation.
With a custom service host, you can basically do whatever you feel is necessary and useful – just create a descendant from
ServiceHostand do whatever you need to do!