为什么我的.NET服务开始在XP启动很慢 [英] Why does my .NET service start really slow on a XP boot

查看:189
本文介绍了为什么我的.NET服务开始在XP启动很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.net窗口服务,充当主机的一些WCF。在OnStart方法的服务主机创建和启动。该服务设置为自动启动。这种运作良好,在Windows 7(32位和64位),它可以是startet在Windows XP专业版SP3NET START。该服务的启动用net start命令大约需要20秒。

I have a .NET windows service which acts as a host for some wcf. In the OnStart method the service hosts are created and started. The service is configured to startup automatically. This works well on Windows 7 (32bit and 64bit) and it can be startet with "net start" on Windows XP Pro SP3. The service startup with "net start" command takes about 20 seconds.

不过,当Windows XP专业版SP3的启动有在事件日志超时消息。该服务本身没有不启动,但做它的依赖。这个问题可以复制在不同的XP机器。核心数和内存没有产生影响。的更新是最新的。

But when Windows XP Pro SP3 is booting there's a timeout message in the event log. The service itself does not fail to startup, though do its dependencies. The problem can be reproduced on various XP machines. Core count and memory does not have an influence. The updates are up to date.

现在它越来越好奇:我分析了跟踪,发现该服务的启动需要大约60秒。因此,我添加了一个调用ReqestAdditionalTime(480000)。但是,现在的服务稍微花费480多秒。的关系是明显的。时间消耗在以下code部分:

Now it's getting curious: I analyzed the trace and found out that the service is taking about 60 seconds for startup. Thus I've added a call to ReqestAdditionalTime(480000). But now the service takes slightly more than 480 seconds. The relation is obvious. The time is consumed in the following code section:

 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 happening here?

推荐答案

嘿,我找到了解决自己做一些密集的对数的研究。

Hey, I found the resolution myself by doing some intensive Log-Research.

在事件日志中有一些服务,这些服务开始后,我的服务达到超时。由于我的服务正在运行作为特异型用户,我可以检测两个服务,在这里实际上可以由我自己的服务触发。因此,我加入到这些服务的依赖和它的作品。

In the event log there were some services, which started AFTER the timeout of my service has been reached. As my service is running as a sepecial user, I could detect two services, which where acutally triggered by my own service. Thus I added those to the services dependencies and it works.

我不知道是否有一个文件,其中WCF的依赖列。 由于参考这里的服务,我的服务dependen的:

I wonder if there's a documentation, where the dependencies of wcf are listed. As reference here are the services, my service is dependen on:

  • HTTP
  • RPCSS
  • CryptSvc
  • HTTPFilter
  • RasMan验证

后两种,其中那些造成僵局。

Latter two where those causing the deadlock.

这篇关于为什么我的.NET服务开始在XP启动很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆