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

Exception thrown in case of Trigger type "TimeTrigger"

Topics: Errors
Apr 3 at 7:18 AM
Edited Apr 3 at 11:13 AM
Hi,

I am trying to set task to be scheduled only once. Thus, I am using TimeTrigger , but I get the exception at
ts.RootFolder.RegisterTaskDefinition(Curr_Task.Name, Curr_Task.Definition, TaskCreation.CreateOrUpdate, str_username, str_password, TaskLogonType.Password);
Edit : I get this error every time, I try to update the TaskDefinition using RegisterTaskDefinitiom. But for the very first time it works fine.

Exception Details :-
Error Code : -2147216615
Error msg : (10,8):StartBoundary
Stack Trace :
   at Microsoft.Win32.TaskScheduler.V2Interop.ITaskFolder.RegisterTaskDefinition(String Path, ITaskDefinition pDefinition, Int32 flags, Object UserId, Object password, TaskLogonType LogonType, Object sddl)
   at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String path, TaskDefinition definition, TaskCreation createType, String userId, String password, TaskLogonType logonType, String sddl) in D:\Jeet\Task Schedular API v2.5.22\Source Code\TaskService\TaskFolder.cs:line 424
   at SQScheduler.frmScheduleScenario.SetTriggerinTaskScheduler_New()
Please help why I get this exception and what can be done to stop it from coming...
Coordinator
Apr 3 at 10:31 PM
You need to set the StartBoundry of the Trigger to a value in the future.
Marked as answer by JDOSHI on 4/6/2017 at 11:33 PM
Apr 4 at 7:24 AM
Edited Apr 4 at 7:26 AM
I just debug the code and got to know that Add(Trigger unboundTrigger) of TriggerCollection class, sets it to null while calling Bind(v2Def). Please check the below snaps for the same.

Before Call
https://drive.google.com/open?id=0B5gc8M5EOKshMThSek9IQ1hBbzg

After Call
https://drive.google.com/open?id=0B5gc8M5EOKshTkxYY01WYnhDNlk

I have scenario in which I clear all the triggers and add the triggers again to the Task. Some of them are the existing triggers while some can be new. In case of existing trigger(say T1), T1 does get added but with the time set as current Time(and not the future once), then I do different things and at last I call RegisterTaskDefinition.

At this moment, the StartBoundary of T1 is less than Current Time. Thus, the exception is thrown.

Now. Please suggest a way to clear the existing triggers and add triggers again such that this issue does not occur.