在执行托管应用程序时,.NET 执行的最耗时的检查是什么?

发布于 2024-08-19 03:05:40 字数 717 浏览 6 评论 0原文

我开发了一个基于 .NET 的 Windows 服务,该服务使用部分托管 (C#) 和非托管代码(C/C++ 库)。

在某些域环境中(例如域abc.com内的Win 2k3 32位服务器)有时服务需要超过30秒才能启动(特别是操作系统重新启动时),从而无法启动服务。我怀疑这与企业级安全有关,但我不确定。

http://msdn.microsoft.com/en- us/library/aa720255%28VS.71%29.aspx

我尝试了以下操作但没有成功: - 通过将 using 指令尽可能远离服务库实现来延迟加载引用(尤其是 xml 命名空间 - 知道会导致加载延迟) - 延迟加载和配置log4net - 使用ngen预编译代码 - 延迟工作线程的启动 - 添加/删除清单+内部设置的礼仪 - 签署/取消签署二进制文件 - 尽可能稍后使用配置设置(有很多设置,所有设置的范围级别都设置为应用程序) - 将所有依赖项添加到 GAC

我还没有尝试为已实现 Main 方法的类添加安全要求。 我没有尝试实现自己的配置加载器,因为在检查自动生成的代码后,我注意到设置类是单例,并且它在调用时获取其实例。

通过完全删除 log4net 依赖项,它可以工作,但这不是一个选项。

当网卡被禁用时,服务立即启动。

I've developed a .NET based Windows service that uses part managed (C#) and unmanaged code (C/C++ libraries).

In some domain environments (e.g. Win 2k3 32bit server inside domain abc.com) sometimes the service takes more than 30 seconds to start (especially on OS restart), thus failing to start the service. I suspect that it has something to do with enterprise level security but I do not know for sure.

http://msdn.microsoft.com/en-us/library/aa720255%28VS.71%29.aspx

I've tried the following without success:
- delay loading references by moving the using directives as far as possible from the servicebase implementation (especially the xml namespace - know to cause delays in loading)
- delay loading and configuring log4net
- precompiling the code by using ngen
- delaying the start of the worker thread
- add/remove manifest + decencies set inside
- sign/unsign the binaries
- use the configuration settings (there are a lot of settings and the scope level for all is set to application ) as later as possible
- add all dependencies to GAC

I didn't tried yet to add security demands for the class that has the Main method implemented.
I didn't tries to implement my own configuration loader because after inspecting the autogenerated code, I've noticed that the setting class is a singletone and it gets its instance on call.

By completely removing the log4net dependency it worked, but this is not an option.

When the network card is disabled the service starts immediately.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

话少心凉 2024-08-26 03:05:40

您通常会使用 SysInternals 的进程监视器来诊断此问题。事实上,这是一项服务,这让事情变得复杂起来。请查看此博客文章,了解类似的故障排除会话。

顺便说一句,它就像 CRL(证书撤销列表)问题一样嘎嘎作响。要禁用它:“控制面板”、“Internet 选项”、“高级”选项卡、“安全”,取消选中“检查发布者的证书吊销”。

You'd normally use SysInternals' Process Monitor to diagnose this problem. The fact that this is a service complicates matters. Check this blog post for a similar troubleshooting session.

It quacks like a CRL (Certification Revocation List) problem btw. To disable it: Control Panel, Internet Options, Advanced tab, Security, untick "Check for publisher's certificate revocation".

霞映澄塘 2024-08-26 03:05:40

我们发现使用具有名称解析(甚至到 12.0.0.1)的 log4net UDP 附加程序会导致启动速度大幅减慢。

We discovered that using a log4net UDP appender with a name resolution (even to 12.0.0.1) was causing a massive slow down in start up.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文