Rotem.O
Rotem.O

Reputation: 103

wcf windows service recovery program

I have a windows service hosting a WCF server. I used "sc config...." and "sc failure..." to set the following properties: 1) log on credentials - local user 2) recovery - restart the service for the first 2 failures, and then run a program (.bat or .cmd)

I tried to test it with several ways of crashing the service, but non of them kicked in the recovery. I tried via task manager, taskkil, throwing exception within the code, divide by zero...

and nothing happend - not the restart nor the run a program. Any ideas?

Upvotes: 1

Views: 156

Answers (1)

Ross Bush
Ross Bush

Reputation: 15175

I bet that wcf service is spawned out in a thread from the containing service and the main thread is not exiting for child thrown exceptions as you are expecting.

See this article.

Since this exception is being thrown on a different thread than the main thread, I need to subscribe to the AppDomain’s UnhandledException event. If I don’t do this the thread will just die silently and the service will continue to run, which is not what I want.

Upvotes: 1

Related Questions