Reputation: 9578
A WCF service is hosted in a Windows Service (WS).
When the database (SqlServer 2005) goes down a SqlException is thrown due to the actions performed on the database.
What I want to accomplish is that the WS - where the WCF service is hosted - should go down when the DB is also down.
The WS will be restarted manually by the way.
My idea is to do nothing about it. The unhandled exception will stop the WS.
Is this the correct way to do ?
Upvotes: 2
Views: 1436
Reputation: 755491
If you want to explicitly stop your windows service, just call the .Stop() method on your service class.
Windows services can be configured to automatically restart on error - so just letting the SqlException flow to the top might not achieve what you want.
Marc
Upvotes: 2
Reputation: 10987
First of all you need to detect that SQL server went down from the SQLException you will get. Secondly why to kill the webservice instead return an error to client saying service is down temporarily for so and so reason.
Upvotes: 1