开发者

Determining the reason why a .net windows-service won't start

I am trying to determine why a .Net service that I can successfully install on a wide number of machines won't start on certain machines.

When the service is started on these m开发者_JAVA百科achines the service instantly stops, so my assumptions are either that the users doesn't have sufficient privileges to install the service or that there is an issue with the service; however, both of these conditions are false (the service works and they have sufficient privileges).

What are some steps I should take to determine the reason the service won't start?


The Application event log should contain details of any .Net exceptions that occurred during service startup. This may help diagnose the problem.

Alternatively, you can add some debug code (or trace code) to your application startup and use debugview from Sysinternals to see where it gets to.


So I figured this out, thanks to looking at the event log from @Matthew Steeples and @Ben M.

The issue was the service writes to the event log on start when it connects up to a server; however, this machines event log was full, so when the service tried to write to the event log it failed, causing it to throw an exception which again couldn't be written to the full event log.

So case in point, if you are writing to the event log make sure it isn't full or that you are handling the exception!


Look in Event Viewer -> Windows Logs -> Application

This should show uncaught exceptions. In my case, I was expecting that the current directory would be the location of the service EXE, however it turns out that it is actually %WinDir%\System32 so I needed to modify my application to get the EXE directory and use that when accessing files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜