Why does my .NET service start very slowly when loading XP
I have a Windows .NET service that acts as a host for some wcf. Service nodes are created and started in the OnStart method. The service is configured to start automatically. This works well on Windows 7 (32 bit and 64 bit), and it can be cleaned up on Windows XP Pro SP3. It takes about 20 seconds to start the service with the "net start" command.
But when Windows XP Pro SP3 loads there a timeout message in the event log. The service itself does not start, although it depends on it. The problem can be reproduced on different XP computers. The number of cores and memory are not affected. Updates updated.
Now it became curious: I analyzed the trace and found out that it takes about 60 seconds to start. So I added a call to ReqestAdditionalTime (480000). But now the service takes just over 480 seconds. The attitude is obvious. Time is consumed in the following section of code:
var asyncResults = new List<IAsyncResult>();
foreach (var host in myHosts)
asyncResults.Add(host.BeginOpen(null, host));
// wait until finished
while (asyncResults.Count != 0)
{
IAsyncResult ar = asyncResults[0];
if (!ar.IsCompleted) ar.AsyncWaitHandle.WaitOne(1000);
if (ar.IsCompleted)
{
asyncResults.Remove(ar);
var co = (ICommunicationObject)ar.AsyncState;
try
{
co.EndOpen(ar);
}
catch (Exception ex)
{
...
}
}
}
Do you have any idea what's going on here?
a source to share
Hey, I found the solution myself by doing some intensive Log-Research.
There were some services in the event log that started AFTER my service timed out. Since my service is running as a separate user, I might find two services that are typically started by my own service. So I added them to the service dependencies and it works.
I wonder if there is documentation that lists the wcf dependencies. Services are given as a reference, my service depends on:
- HTTP
- RPCSS
- CryptSvc
- HTTPFilter
- RASMAN
The last two, where are the ones that cause a dead end.
a source to share