I know how to connect a debugger to a Windows service, but I cannot connect to the one that is installed and started by the window installer. I tried:
Setting Thread.Sleep (TimeSpan.FromSeconds (30)); at the beginning of on-start, but when I try to connect in Visual Studio, the service name does not appear as an option. This works fine, the service name is displayed in the list, but this is not the case with the installer.
Configuring Debugger.Break and Debugger.Launch. They donβt do anything.
What can I do to debug my service?
Update:
I added Thread.Sleep for 30 seconds as the first line of the service, and when the installer tells me what it should do when it fails, I start the service in the list of services (since it has not been deleted) and it does not work instantly without 30 seconds of waiting. The files that it installs are the last (they have the correct modified time). A 30 second pause occurs if I start the same client from my test application in the same project, but for some reason the installer is screwing something.
I'm really not sure how to debug this, and it is disappointing that this service worked correctly.
Answer:
Checking the application log showed me the exception that was thrown. It turned out that I accidentally mounted the file in my installer, which explains why none of my debugging methods worked. As soon as I restored the file, I was able to connect with the visual studio as usual (using a 30 second pause to give me time).
source share