Few things I have learned on debugging windows services that might help you in troubleshooting your issue.
- Try to log everything for each method inside your windows service to text file as Tim suggested in the comment.
Try to catch UnhandledException before the service exits by adding an event handler to the appdomain. I have my Log function that writes to text file.
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException
Public Sub CurrentDomain_UnhandledException(sender As Object, e As UnhandledExceptionEventArgs) 'Log and output exception message before the application exits. Dim exp = DirectCast(e.ExceptionObject, Exception) Dim formatexp = String.Format("Exception: {0}; Message: {1}: InnerException: {2}", exp.ToString(), exp.Message.ToString(), exp.InnerException.ToString()) Log(formatexp) Console.WriteLine(formatexp) Log("Application exited due to unhandled exception") Console.WriteLine("Service exited due to unhandled exception") 'Exit the batch process gracefully. Environment.Exit(-1) End Sub
Try using WindDbg for debugging Windows Service Crash or Hang issues and you can download it from Microsoft Download site.
Check if service account that is trying to access any resource on the server has access to them.
If you want to see real time execution of your code then log execution to a SignalR Host. This might be overkill but I once had multiple threads executing different processes and I was able to debug an issue using SignalR.
Note: If you can post some sample code then it would be helpful to us in helping you out.