This project has moved. For the latest updates, please go here.

Problem between Version 1 and Version 2

Apr 15, 2011 at 2:21 PM
Edited Apr 15, 2011 at 3:48 PM

I use version 1 setting for a XP machine and i cannot set Daily Trigger, neither Weekly trigger. But everything work fine on my Win7 machine. I have invalid range value exception on my XP machine. Any idea?

 

I have this error on:

 

td.Triggers.Add(trigger);

 

The trigger contain :

{Trigger Type: RunDaily;\n> Start: 2011-04-15 01:01:00; End: 2011-04-26 00:00:00;\n> DurMin: 0; DurItv: 1;\n>}

Type version1... when version2 all work fine.

The Trigger is made with this code:

        Trigger trigger = new DailyTrigger()
         {
            Enabled = true,
            StartBoundary = executionTime,
            DaysInterval = (short)scheduleDaily.IntervalDays,
            EndBoundary = endingTime
         };


-Edit : 
I have referenced the code of your library and the problem occur in SetV1TriggerData>():
You can see a screenshot : http://clip2net.com/clip/m12122/1302878625-clip-47kb.png
Complete error message:
System.ArgumentException occurred  Message=Value does not fall within the expected range.  Source=Microsoft.Win32.TaskScheduler  StackTrace:       at Microsoft.Win32.TaskScheduler.V1Interop.ITaskTrigger.SetTrigger(TaskTrigger& Trigger)       at Microsoft.Win32.TaskScheduler.Trigger.SetV1TriggerData() in C:\dev\20-LabPlusV3\Trunk\Tools\TaskScheduler\TaskService\Trigger.cs:line 606  InnerException: 
Stack:

   at Microsoft.Win32.TaskScheduler.V1Interop.ITaskTrigger.SetTrigger(TaskTrigger& Trigger)   at Microsoft.Win32.TaskScheduler.Trigger.SetV1TriggerData() in C:\dev\20-LabPlusV3\Trunk\Tools\TaskScheduler\TaskService\Trigger.cs:line 606
Coordinator
Apr 15, 2011 at 6:24 PM

I just ran the following under XP without any problems:

td.Triggers.Add(new DailyTrigger() { Enabled = true, StartBoundary = DateTime.Now, DaysInterval = 1, EndBoundary = DateTime.Now + TimeSpan.FromDays(14) });

That leads me to believe it is a problem with one of the properties. In the screenshot you provided, I would ask that you provide me the full detail of the v1TriggerData structure. That will let me see if there is some property that will cause the error you're seeing. That error, by the way, is from the Microsoft core library saying that something with the structure is amiss.

Apr 15, 2011 at 6:44 PM
Edited Apr 15, 2011 at 6:51 PM

Sure here is the structure :

Part1:

http://clip2net.com/clip/m12122/1302889422-clip-30kb.png

Part2:

http://clip2net.com/clip/m12122/1302889452-clip-29kb.png

Part3:

http://clip2net.com/clip/m12122/1302889612-clip-12kb.png

 

I want to add that UniqueTrigger work :P bot not the daily and weekly. Monthly seems to work too. Confusing :S

Coordinator
Apr 15, 2011 at 7:16 PM

Found your issue. Under V1, the Trigger.Repetition.Duration specified must be greater than or equal to the Trigger.Repetition.Interval setting.

Apr 18, 2011 at 3:42 PM

 

            var interval = new TimeSpan(0, scheduleDaily.IntervalMinutes, 0);
            trigger.Repetition.Interval = interval;
            trigger.Repetition.Duration = interval;//Must be greater or equal of Interval with V1

Does not work...
Apr 18, 2011 at 4:52 PM

Ok it work if I add +1 to the interval for duration.

It's not equal or greater but just greater.

I think the API should handle those type of stuff for V1. Thanks for you help.

Coordinator
Apr 18, 2011 at 8:44 PM

Thanks for the suggestion. I'll look into including that error checking in the next release. Interestingly enough, there is a discrepancy in the Microsoft help for V1. I quoted the incorrect one obviously. Thanks for testing and posting your findings.

Just for clarity for other readers, Repetition.Interval must be less than Repetition.Duration when adding triggers to a V1 task.