如何使用c#启动Windows服务? [英] How can I start a windows service using c#?

查看:186
本文介绍了如何使用c#启动Windows服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经创建了一个Windows服务并成功安装了它。但我无法启动它。每当我尝试启动它时都会出现以下消息。



< service name =>本地计算机上的服务已启动然后停止。某些服务停止如果他们没有被其他服务或程序使用,则会自动。



请建议我如何开始这项服务。

谢谢。

Hi,
I have created a windows service and installed it successfully. But I am not able to start it. The following message comes whenever I try to start it.

"The <service name=""> Service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs".

Please suggest me how to start this service.
Thank you.

推荐答案

你必须调试它。它可能会出错。我建议你查看事件查看器。另外,请确保登录帐户具有适当的权限,以执行您的服务。



最后,请确保您的服务不是其中一种消息提及,仅供其他服务或程序使用,不需要经常运行。
You'll have to debug it. It could be getting an error. I suggest you look in the Event Viewer. Also make sure the Log On account has the proper permissions to do whatever it is your service does.

And lastly, make sure your service is not one of the kinds the message mentions, one that is only used by other services or programs and doesn't need to be constantly running.


这篇关于如何使用c#启动Windows服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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