开发者

Framework for hosting WCF services in Windows Service

Does anyone know of a framework that would allow me to easily host and configure WCF services within a Windows Service?

Originally I had developed a system where a single host application contained one Windows Service per service host so that the administrators could manage these services individually in the Services applet.

However, other systems are coming on-line with an increasing number of WCF services that would need to be hosted this way and there is growing concern that this will become too complex to manage through the Services applet.开发者_Python百科

The requirements coming from above are that we need the ability to configure what services are hosted within the Windows Service, start and stop them as required, and allow for easy deployments.

I believe that within the service we could host a management WCF service that would allow us to control the behaviour of the other services but if someone has already created a framework for doing this I am more than happy to use the wheel that has already been invented.


Well, hosting a WCF service in a Windows NT Service isn't really all that hard - so I don't think there's a big "framework" available for that...

Basically, you need to

  • declare a ServiceHost variable for each WCF Service you want to host
  • in the OnStart() method override of the NT Service, you instantiate and open the service hosts
  • in the OnStop() method of the NT Service, you close the service hosts again

That's about all there is - so what aspect did you want to delegate to a framework in this scenario? What other aspects or problems do you have that need to be handled?

If you want to influence separate service instances inside a single NT Service, you'll have to check into the OnCustomCommand method override on your NT Service class.

From the outside, you can create a ServiceController and then call ExecuteCommand on that controller. Unfortunately, you can only send in a single int as a parameter.

So I guess in this case, you'd have to define e.g. a "service constant" for each service, e.g. const int MyService1 = 10; const int MyServive2 = 20; and then use that base service constant to start the WCF service, that base constant + 1 to stop it, or something along those lines.


Seems like this app matches some what you're looking for. It can dynamically host wcf services and has a UI for managing it.

Framework for hosting WCF services in Windows Service


(source: wcfstorm.com)

App : http://www.wcfstorm.com/wcf/getting-started-with-wcfstormhost.aspx


This comes down to personal opinion. I see no problem with controlling a hundred different services via the standard MMC snap-in. It also allows a network admin to manage them centrally for the entire domain using WMI, PowerShell, commercial tools, etc. If you roll your own management system, you give up this kind of easy centralised control.

As for deployment, just create one custom action to install all the services in one go.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜