Window Service无法重新启动 [英] Window Service not restarting

查看:82
本文介绍了Window Service无法重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个用c#创建的窗口服务。这项服务会自动发送邮件。



但我的问题是,如果收到错误的emailID,则会发生异常并且服务停止。

我也是在第一次失败,第二次失败等时设置服务属性。

我还编写了使用服务控制重启服务的代码。但我的服务仍然没有重新启动。



请帮我解决这个问题。

提前致谢。

任何帮助将不胜感激。



Sandeep beniwal

9468479258

Hi
I have a window service created in c#. This service sends mail automatically.

But my prob is that if a wrong emailID get then an exception occurs and service stops.
I also set the property of service on first failure , 2nd failure , and so on .
I also write code for restarting service using service control. But my service still not restarting.

Please help me to get out of this problem.
Thanks in advance .
Any help will be appreciated.

Sandeep beniwal
9468479258

推荐答案

我们总是使用两个常见事件:



OnStart

OnStop



你可以写OnStart



如果你的SmtpMail.Send(消息)方法没有返回错误,这意味着电子邮件被发送到SMTP服务器,然后你超出您的管辖范围,这是您可以知道的距离。不要使用异常,它会使服务停止。



然后你可以做你需要的任何事情。
we are always use two common event:

OnStart
OnStop

You can write on OnStart

if your SmtpMail.Send(message) method returns no error, it means the email was sent to the SMTP server, then you are out of your jurisdiction, that is how far you can know. Not use exception in that and it make service stop.

Then you can do anything what you need.


这篇关于Window Service无法重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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