c# - Reasons for windows service to stop -
I have designed a Windows service in C #, which runs continuously and creates three threads. The first thread runs every 15 seconds The second thread runs every minute and thirs only runs once.
My problem is that these windows are somehow closed after a few days. Nothing is logged in the eventlog on the day of the stop. And it did not write anything logging file.
I want to know that several reasons for a windows can be suddenly shut down and this service is not on my DEV box, it is on the QA server.
Hope this makes sense!
You probably have an unused exception on one of your threads - since the .NET 2.0, Unscrupulous exceptions will take the process down suddenly like this. Ensure that there is a catch block to handle errors above the stack for any thing running on a thread (log, swallow, martial to the other thread, whatever). You can temporarily stop this behavior by adding the following to your service .exe.config file (such as returning to pre-.NET 2.0 behavior):
& lt; Configuration & gt; & Lt; Order & gt; & Lt; LegacyUnhandledExceptionPolicy enabled = "1" /> & Lt; / Order & gt; & Lt; / Configuration & gt;
But do not trust him - it can be removed in the future. Net release (4.0 is not checked - it can already be done)
Comments
Post a Comment