带有WCF的Windows服务 [英] Windows Service with WCF

查看:85
本文介绍了带有WCF的Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我是Windows&的新手. WCF服务.我需要使用"Windows服务"在C#中编写服务.
没有托管WCF服务,是否有可能从WCF校准Windows服务.
请帮忙

问候
Aabidha

Hi Guys,
I am very new to Windows & WCF service.I need to write service in C# using "windows service".
Is there any possibility to cal windows service from WCF without hosting WCF service.
Plz do help

Regards
Aabidha

推荐答案

您只能通过服务控制器运行Windows服务.服务控制器具有可用于启动/停止/重新启动服务的API.

使用类System.ServiceProcess.ServiceController,请参见 http://msdn.microsoft.com/zh-我们/library/system.serviceprocess.servicecontroller.aspx [ ^ ].

现在,我不知道从WCF调用Windows服务"的含义是什么? WCF不是服务,应用程序也不是过程,它是Windows Communication Foundation,从本质上来说,是一种库和技术.如果可以使用Service Controller API和/或WCF编写一些.NET代码,则可以从此代码控制服务.这取决于你是什么.

这就是解决Windows服务控制问题所需要的.

顺便说一句,为什么不在您的服务中自托管WCF?我认为Windows服务是WCF服务器部分的理想主机.不过,这取决于您.我提到它只是为了引起您的注意:您确定真的了解WCF托管是什么吗?如果您愿意,我很抱歉,对您有好处.但是,如果您解释为什么不通过服务使用自我托管,那就太好了.如果您有更好的主意,我很想知道这是什么.

—SA
You can only run a Windows Service by the Service Controller. The Service Controller has API which you can use to Start/Stop/Restart service.

Use the class System.ServiceProcess.ServiceController, see http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx[^].

Now, I have no idea what that supposed to mean, "to call Windows Service from WCF"? WCF is not a Service, Application or a process, this is Windows Communication Foundation, essentially, a library and technology. If you can make some .NET code using Service Controller API and/or WCF, you can control a Service from this code. It''s up to you what is that.

This is all you need to solve your problem of controlling a Windows Service.

By the way, why not self-hosting WCF in your Service? In my opinion, a Windows Service is a perfect host for WCF server part. This is up to you though. I mentioned it just to bring your attention to this: are you sure you really understand what is WCF hosting? If you do — my apologies, good for you. However, it would be nice if you explain why not using self-hosting by your Service. If you have a better idea, I would do curious to know what is it.

—SA


这篇关于带有WCF的Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆