Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling CoCreateInstance during service startup

I have a windows service, that makes several COM+ calls during initialization. On some systems this windows service causes a deadlock during startup.

At least one service or driver failed during system startup

The problem with calling CoCreateInstance during service startup is that it might require other services to startup. And the SCM will not allow other services to startup while waiting for the current service to enter running state. The solution is to ensure that the service dependencies are properly configured when installing the service. See http://support.microsoft.com/kb/258943

But what services dependencies should one specify when running on Windows Vista / 2008 / 7 ?

like image 239
Rolf Kristensen Avatar asked Apr 28 '26 02:04

Rolf Kristensen


1 Answers

Another solution is to not initialize your COM objects during your service startup logic at all. Have the startup logic create a separate worker thread, or at least a delayed/queued request to itself, so the COM initialization can be done after the SCM has been freed to start the other services as needed.

like image 94
Remy Lebeau Avatar answered Apr 30 '26 15:04

Remy Lebeau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!