Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Lifecycle Events

Tags:

.net

wcf

Is there an event that fires when a WCF service gets started or shut down? Hopefully, independent of whether it is self hosted or hosted in IIS?

like image 690
Jake Pearson Avatar asked Nov 03 '08 18:11

Jake Pearson


2 Answers

ServiceHost exposes quite a few events:

http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehost_events.aspx

You could hook into these events by using a custom service behavior:

http://msdn.microsoft.com/en-us/library/system.servicemodel.description.iservicebehavior.aspx

like image 171
jezell Avatar answered Sep 23 '22 09:09

jezell


Sure, the constructor of your object (especially if you are using a Singleton style). Please pardon the shameless self promotion, but I've written two articles on how to get started with a WCF (Net.Tcp) client/server system... The first is non-IIS (to which the service starts on your own terms), the latter is how to modify the first to be hosted in IIS to which my first sentense would apply:

1) Client Server Programming with WCF

2) Duplex WCF Services Hosted in IIS Using Net.Tcp

like image 41
Timothy Khouri Avatar answered Sep 23 '22 09:09

Timothy Khouri