Getting ArgumentException when adding MonthlyDOWTrigger to Triggers collection

Aug 15, 2011 at 1:39 PM


I am new to C# world and just started to use this library. My company is a little behind on development tool so I am still on Visual Studio 2005. My OS is Windows XP SP3.

Here is my test code snippet:

TaskDefinition tDefinition = tService.NewTask();
MonthlyDOWTrigger trigger = new MonthlyDOWTrigger(DaysOfTheWeek.Monday, MonthsOfTheYear.January, WhichWeek.FirstWeek);     
trigger.Enabled = true;

When it is executed, the last line gives me ArgumentException:

System.Argumentexception: Value does not fall within the expected range.
  at Microsoft.Win32.TaskScheduler.V1Interop.ITaskTrigger.SetTrigger(TaskTrigger& Trigger)
  at Microsoft.Win32.TaskScheduler.Trigger.SetV1TriggerData()
  at Microsoft.Win32.TaskScheduler.Trigger.Bind(ITask iTask)
  at Microsoft.Win32.TaskScheduler.TriggerCollection.Add(Trigger unboundTrigger)

Any idea what I am doing wrong?

Thanks for your help!

Aug 15, 2011 at 4:44 PM

You have uncovered a bug for V1. It is corrected in source release 69701 and will be released in version 1.6.4 of the library. Right now there is no simple workaround with 1.6.3 that can be identified.