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

2 Answers2

2

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

Jonas
  • 4,454
  • 3
  • 37
  • 45
  • 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 Anthony Hein Jun 15 '09 at 23:14
  • Yeah, this is a decent suggestion. – Noldorin Jun 15 '09 at 23:14
  • 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 Jun 15 '09 at 23:16
  • Thanks, I'll look into what it could be. –  Jun 15 '09 at 23:18
  • 3
    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 Jun 16 '09 at 00:10
  • @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 Anthony Hein Jun 16 '09 at 00:26
1

You can fix this by adding a dependency to the Windows Management Instrumentation service (winmgmt.exe).

Please see my answer here: https://stackoverflow.com/a/13454379/1003958

Community
  • 1
  • 1