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

Posted by ltorje on Stack Overflow See other posts from Stack Overflow or by ltorje
Published on 2010-01-28T06:29:18Z Indexed on 2010/03/28 20:53 UTC
Read the original article Hit count: 286

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.

Any suggestions/comments/solution you have would be most welcomed.

© Stack Overflow or respective owner

Related posts about c#

Related posts about windows-services