Collecting Coverage Data on Large Services

Collecting Coverage Data on Large Services

Collecting coverage data on large assemblies can be tricky at times. When the CLR loads an assembly, NCover analyzes the assembly to note the classes and methods that it contains. In most situations this analysis takes less than a second, but some projects with large assemblies (many megabytes) can run into longer load times.

Yesterday an NCover user reported an interesting issue when running NCover on a service. The user reported that he would start collecting coverage data on the service, it would run for about 30 seconds, and then the service would die. We asked him to send us a copy of the NCover log, and it looked an awful lot like an unhandled exception was occurring in his application. The only problem was, when he ran the service normally, no unhandled exception occurred.

It turns out that Windows Service Manager only gives a service 30 seconds to start by default, and then it ends the service's process, assuming that something is wrong. In order to get the Service Manager to wait long enough for the service to initialize properly, we need to increase the service timeout. That timeout can be overridden with a Windows registry key. To override it, open up regedit, and browse to

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control

If it's not already there, create a new DWORD value named ServicesPipeTimeout. Set the value of that key to the number of milliseconds that you would like Windows Service Manager to give your service to start up.

Problems like this can be pretty tough to solve, so please don't hesitate to contact us when you run into issues. Just submit a ticket through the support section of the website, and someone from our support team will help you troubleshoot your problem.