开发者

What are the most time consuming checks performed by .NET when executing a managed application?

开发者 https://www.devze.com 2022-12-18 20:56 出处:网络
I\'ve developed a .NET based Windows service that uses part managed (C#) and unmanaged code (C/C++ libraries).

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开发者_C百科 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.


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".


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消