0

I am currently writing a windows service and normally used to writing web applications in c#. Therefore I have some questions that more experienced programmers of windows services may be able to answer.

How are exceptions normally handled in a windows service, logged to event viewer, text file etc?

Normally when I write a web application I use an installer with custom actions to install it. Can I create the same for a windows service and install it similarly?

Finally, anyone have experience as to how to hook up spring.net dependency injection in to a windows service?

amateur
  • 43,371
  • 65
  • 192
  • 320

1 Answers1

1

There is a huge gap between recoverable and unrecoverable errors. You can overcome recoverable ones but you cannot do unrecoverable. So for unrecoverable errors I would recommend persist your error and shut down your service. For recoverable ones you can continue you execution loop. There is some more information in this answer. To log something to event log use EventLog class from the BCL library. More details on it in MSDN

Yes, you can make an installer for a windows service. Implementation is pretty much the same. The tool I would recommend to look for installation while not in production is installutil

I made integration of windows service with AutoFac container. You have to instantiate and configure your container after start. Unfortunately I don't have any Spring specific experience, so if your question is about some specifics I have no clue on it. But if it's general question on DI container integration that shot it. Just in case: there is some time limitation of service to start.

Community
  • 1
  • 1
amdmax
  • 771
  • 3
  • 14