views:

787

answers:

1

I get the error below in the event log when the computer boots, the service is set to automatically start, when I manually start the service it starts without a problem.

Any ideas?

Service cannot be started. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80010002): Call was canceled by the message filter. (Exception from HRESULT: 0x80010002 (RPC_E_CALL_CANCELED)) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)

Thanks

+3  A: 

Does your service depend on some other component/service that may not have started up yet at machine boot?

Jonas
Jonas is probably right, so to test it out, try putting in a Thread.Sleep call for a decent amount of time, during your start up event before any work begins.
Richard Hein
Yeah, this is a decent suggestion.
Noldorin
We have this same problem at our company with a service depending on SQL to be started before our service is started...I think we have a timer that tries a configurable number of times before giving up.
Jonas
Thanks, I'll look into what it could be.
You can make your service dependent on other services in configuration, and therefore no need to sleep an arbitrary amount of time - your service will simply not be started until its dependent services are running.
Alan Moore
@Alan Right on; to find out what services your service depends on, if you are unsure, go to Administrative Tools - Services, bring up Properties on your service, and check the Dependencies tab.
Richard Hein