This project has moved and is read-only. For the latest updates, please go here.

ComHandlerAction Example

Jul 1, 2009 at 6:43 PM

Can you post an example of how to using the ComHandlerAction, including an implementation of the ITaskHandler COM interface.


Jul 4, 2009 at 2:52 PM

I am interested to use this library in my application for firing an event at a certain scheduled time. In this scenario I suppose that ComHandlerAction is good for me but I have no example how to use it.  Besides surely the scheduling code will be implemented within a thread so it is important the library to be thread-safe. Have you never used the library in this context ?


Jul 8, 2009 at 8:10 PM

This library wraps (hides) the ITaskScheduler COM interface. The ComHandlerAction class wraps the functionality of the IComHandlerAction interface in the Task Scheduler 2.0 library. It effectively loads the specified COM object and executes methods found in the mandatory exposed interface ITaskHandler. For more information, go to To fire an event at a certain scheduled time you could create a COM object that exposes an ITaskHandler interface and set the GUID for the COM object in the ComHandlerAction.ClassId property. You then need to create the appropriate trigger to set the time to call the object. (See example code on home page and in other discussion threads.)

As far as thread safety, I don't know as I've never tried it. To my recollection, there isn't much that would be affected if you are creating the instances of the TaskService and TaskDefinition within the same thread. If you try it and have problems, be sure to post an issue.

Jul 9, 2009 at 12:18 AM

This thread peaked my interest. I spent a few hours today figuring out how to create a COM library in C# that can be executed using the COMHandlerAction from the Task Scheduler. The sample project is now in the Downloads section.

Jul 24, 2010 at 5:34 PM

Thank you for supplying this interesting example.

When starting your ComHandler task I get the error:
Task Scheduler failed to launch action "" in instance "{b92b6d19-3e39-4561-a700-4309f8d8be28}" of task "\Meinl\TestComHandler". Additional Data: Error Value: 2147746132.
Last Run Result: 0x80040154

Which seems to mean "class not registered".

What am I doing wrong?

Here is what I did:

1. Built your task in VS as admin
2. Ran the COMTask.reg file (had to convert it from UTF-8 to ASCII first)
3. Created a task via the Task Scheduler UI using the following TestComHandler.XML file
  <Actions Context="Author">

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="">
    <Principal id="Author">
  <Actions Context="Author">

Aug 2, 2010 at 5:00 PM

I just took my code which worked under XP and Vista and am seeing failures under Win7. I will post my solution once I work through the problem.

Jan 7, 2013 at 5:18 PM

This is now working and is available under the Downloads area.

Apr 15, 2014 at 2:15 PM
Error: Task Scheduler failed to launch action "" ..................................

I found one source of this error. I mean the reason why "" is blank and not appearing with task name.

Possible Reason: The assembly is not registered for COM or Not made as COM visible.

  1. Go to the properties window of the your project where the COM Handler is registered.
  2. Click on 'Assembly Information' button.
  3. A checkbox appears which indicates "Mark as COM Visible". Check this.
I guess, some part of this info is provided by Mr. Dahall but I just wanted to share so that you guys can recheck this setting. Thanks.

Apr 16, 2014 at 11:58 AM
Solution to Error:

Task Scheduler failed to launch action "..NotificationCOMService" in instance "{d9fa820c-da53-4ed3-8fc4-4df1e90ef1e1}" of task "\NotiFicaTions". Additional Data: Error Value: 2148734217.

It needs a setting in Assembly properties:
  1. Select your project which has above COMHandler class.
  2. Go to properties. Then click on "Build" tab on left.
  3. At bottom, there is checkbox called - Register for COM interop. Check it.
Now compile the assembly and run the code. Hope your error gets resolved.
Marked as answer by dahall on 4/23/2014 at 8:56 PM