Problems with WCF endpoints hosted from Windows Service

Posted by Dilip on Stack Overflow See other posts from Stack Overflow or by Dilip
Published on 2010-04-28T01:19:19Z Indexed on 2010/04/28 1:23 UTC
Read the original article Hit count: 382

Filed under:
|
|
|

I have a managed Windows Service that hosts a couple of WCF endpoints. The service is set to start automatically when the PC is restarted. On reboot I find that this line of code:

ServiceHost wcfHost1 = new ServiceHost(typeof(WCFHost1));

in the OnStart() method of the service takes somewhere between 15 - 20 seconds to execute. Actually I have two such statements but the second one executes in a flash. It is the first one that takes so long. Does anyone know what could be causing the bottleneck? Because of this, sometimes the call exceeds 30 seconds and as a result the SCM thinks my service timed out while trying to initialize itself. Now, I know its easy for me to just spin off a thread to do this and return from OnStart() right away but I'd like to know what could cause this delay.

This happens only when the service starts up on PC reboot. If the PC is up and running, the service starts & stops in less than a second.

© Stack Overflow or respective owner

Related posts about wcf

Related posts about c#