简体   繁体   English

Windows服务未在特定计算机上启动

[英]windows service not starting on a certain computer

I've written a windows service in C# which basically reads a text file periodically, and inserts its content to SQL Server database. 我已经用C#编写了Windows服务,该服务基本上会定期读取文本文件,并将其内容插入SQL Server数据库。 i've installed this service to over 100 computers in the company and all is working fine except one. 我已经在公司的100多台计算机上安装了此服务,除一台以外,其他所有设备都工作正常。 but when i go to services screen and restart it, it starts working. 但是当我进入服务屏幕并重新启动它时,它开始工作。

based on similar topics in stackoverflow, here is what i did so far: 基于stackoverflow中的类似主题,这是我到目前为止所做的:

1- uninstalled the service and installed again. 1-卸载该服务,然后重新安装。

2- in the properties section of windows service, set it to start automatically (delayed), and restart if failed. 2-在Windows服务的“属性”部分中,将其设置为自动启动(延迟),并在失败时重新启动。

3- did debugging in my computer again and it worked fine, but i don't have any chance to debug in said computer. 3-再次在我的计算机中进行了调试,并且工作正常,但是我没有任何机会在所述计算机中进行调试。

4- the service sends and e-mail to me if there is an error but it sends none, so i am assuming that it's not even starting. 4-该服务会发送并通过电子邮件发送给我,如果有错误,但不会发送给我,因此我假设它甚至没有启动。

What should i do to trace where the error is? 我应该怎么做才能找出错误所在? is there any place where the windows service error logs are stored? Windows服务错误日志存储在什么地方?

You may need to amend your code if you haven't already done so......In the class that inherits from ServiceBase you can set AutoLog to true this will write to the event log which may help. 如果您尚未修改代码,则可能需要修改...在从ServiceBase继承的类中,可以将AutoLog设置为true,这将写入事件日志,这可能会有所帮助。 I'd suggest placing this in the services constructor and reinstalling, if you have some kind of config file perhaps you could modify your code so that you have the option of turning logging on or off. 我建议将其放置在服务构造函数中并重新安装,如果您有某种配置文件,也许可以修改代码,以便选择打开或关闭登录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM