user694071
user694071

Reputation: 73

C# Service Programming Issue with starting

I have written a service and done so using C# with the appropriate service methods etc in the code to start a service, its built and installed as a service, the service starts fine, however I don't see a process running and I also don't see it writing the log it should be writing as an output file. I do notice it picks up if I brute force and click the exe myself however obviously that's not intended behaviour. Any ideas why this may be occurring? I installed it using installutil and started it several ways (services.msc, net start) none of them work really.

Thanks in advance.

Upvotes: 1

Views: 126

Answers (1)

TarkaDaal
TarkaDaal

Reputation: 19595

Have you looked in the Windows Event Log to see if you get messages to say the service has started? Are there any errors in there? If it says it's started, and there aren't any errors, your service was probably started okay, but is failing to do what you want.

Instead of writing to a log file, consider writing to the Event Log - this is the preferred behaviour for services. Log4Net can help with this, but it's not too hard to write yourself.

It's also useful to write your service so that it can also be started from the command line, for debugging purposes. Again, you don't have to do all the work, TopShelf can help with this.

Upvotes: 1

Related Questions