带有WCF的Windows服务

编程入门 行业动态 更新时间:2024-10-27 05:28:25
本文介绍了带有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,请参见 msdn.microsoft/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 msdn.microsoft/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服务

本文发布于:2023-11-14 02:39:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586000.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:WCF   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!