Windows service profiling fails if the service uses a system account
Published 28 August 2014
Profiling a Windows service may fail if the service runs under the System, LocalService or NetworkService account. If the failure occurs, profiling will stop shortly after starting and the service will not run.
The message "System.ServiceProcess.TimeoutException: Time out has expired and the operation has not been completed" may be written to the profiler log.
To work around this problem, run the service under a specific user account instead of a predefined system account.
This failure happens because ANTS Performance Profiler sets a registry value when it enables profiling: if the service runs asSystem, LocalService or NetworkService, the profiler cannot acquire the correct value, and sets an erroneous value instead. The service then uses the erroneous registry value to generate a write path: because the value is incorrect, the path is unusable, and the service fails. Running under a specific user account ensures ANTS Performance Profiler can read the system user environment variable, and will set the correct registry value.