Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 660411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:09:11+00:00 2026-05-13T23:09:11+00:00

I have modified a working Windows service that had always been starting beforehand. After

  • 0

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.

Why won't 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

EDIT: I have added a try-catch statement to catch the exception. Here is the code that I added to the OnStart() method of my service (which is where the exception is being thrown)

        try
        {
            _watcher = new ManagementEventWatcher(query);
            _watcher.EventArrived += new EventArrivedEventHandler(watcher_EventArrived);
            _watcher.Start();  
        }
        catch (Exception ex)
        {
            EventLog.WriteEntry("Could not create Sleep/Resume watcher" + ex.Message);
        }

The service does start now but without the functionality that I have added. I am new to .NET, but I took the watcher code from a sample I found online, so I am pretty sure it is correct. The Event Log displays the same exception:

Could not create Sleep/Resume watcher Call was canceled by the message filter. (Exception from HRESULT: 0x80010002 (RPC_E_CALL_CANCELED))

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:09:11+00:00Added an answer on May 13, 2026 at 11:09 pm

    I ended up using Thread.Sleep(10000) right before I create the ManagementEventWatcher (before the try statement)

    It is kind of a workaround, but it did fix the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have modified my etc/hosts file (under Windows 7), so that www.example.com and demo.example.com
SEE EDIT UPDATES BELOW. Original question has been modified! I have a working window
I'm working on a system where I have a Stream (which is seekable) that
I have a windows service that executes a console app every hour and it's
I create a working repository in HG. And I have modified some files. How
I have a dataset that I have modified into an xml document and then
I have a vs.net project, and after some refactoring, have modified the name of
I have been working and debugging with NetBeans since almost a year with 0
I am currently working on a C# windows form with linq-to-sql that selects a
I have been using git on my windows box to track a project I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.