Why does my .NET Windows service not start automatically sometimes?

Posted by Tomek on Stack Overflow See other posts from Stack Overflow or by Tomek
Published on 2010-03-08T20:41:22Z Indexed on 2010/03/08 21:21 UTC
Read the original article Hit count: 692

Hi all,

I have modified a working Windows service that had always been starting beforehand. After adding the System.Management reference it now sometimes will not start automatically. I get the following error:

Service cannot be started. System.Runtime.InteropServices.COMException (0x80010002): Call was canceled by the message filter. (Exception from HRESULT: 0x80010002 (RPC_E_CALL_CANCELED))

I found another post here on SO with someone having the same issue.

http://stackoverflow.com/questions/998883/why-wont-my-net-windows-service-start-automatically-after-a-reboot

However, the proposed solution was to have the service start after the services it depends on have started. However, when I go to the Dependencies tab for my service, I see:

alt text

Should I just use the workaround method of putting the thread to sleep, or is there a more proper way of getting this service to start correctly? Is this happening because .NET has not started before my service starts?

Thanks,

Tomek

© Stack Overflow or respective owner

Related posts about .NET

Related posts about Windows