WCF singleton hosted in windows service. How to auto start WCF without first "touching" the service with client

c#, wcf

Solution

Yes, use `OnStart` method for this. It will be triggered once the Windows service gets a START command from OS.

Put your "touch" code (logic) there.

Problem

I have a WCF service hosted in windows service. Currently when the windows service starts i have to "touch" the WCF service with a client to run some long running code in WCF service. Is it somehow possible to auto start the long running code in WCF service without calling the service with a client? IIS 7.5 is not an option.

Original source