Issues with WCF Endpoints Hosted in Windows Service

I have a managed Windows service that hosts multiple WCF endpoints. The service starts automatically when you restart your PC. On reboot I find this line of code:

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

      

in the OnStart () method of the service, it takes 15 to 20 seconds to execute. Actually I have two such statements, but the second one is executed in an instant. This is the first one that takes so long. Does anyone know what might be causing the bottleneck? Because of this, sometimes the call exceeds 30 seconds, and as a result, the SCM thinks that my service has been disabled when trying to initialize itself. Now I know that it is easy for me to just spin off the thread to do this and return immediately from OnStart (), but I would like to know what could be causing this delay.

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

+2


a source to share


3 answers


This can provide additional help. Basically, I think you need to figure out what dependencies you have and add them to your service so that they start before yours.

It's just a shot in the dark, but it could be that the .net framework hasn't loaded yet. Perhaps you can try to set auto-start to auto-start with a delay, which will get you started with the .NET framework and other window services.

Also, when a .net application is launched, it is compiled with the Just-In-Time compiler. This may be waiting for .net to compile.



Finally, depending on the type of WCF instance you are using, you may have a problem that the constructor will take some time to initialize.

Hope it helps.

0


a source


I had problems with Windows Service that took a long time. I found out that this was due to the signed assemblies I was using (Enterprise Library) .. NET was trying to validate the Authenticode signature when loading the assembly (maybe your constuctor is using the type the first time, which causes that assembly to load). Just try adding the following to your app.config. When that doesn't work, another problem arises.

<configuration>
    <runtime>
        <generatePublisherEvidence enabled="false"/>
    </runtime>
</configuration>

      



You can also find more information here: http://support.microsoft.com/kb/936707 and Why mine. Net app associated with Verisign?

0


a source


No problem with your WCF service. The best way to solve your problem is to create a dummy operation that the client should call first. This will force your client to complete their handshake on your service prior to your actual transaction. I actually used a dummy operation to call my service from time to time to make sure it is still alive.

0


a source







All Articles