Getting (16,8):StartBoundary: Exception when Schdeduling Task

Topics: Errors
Jan 17 at 6:48 PM

I am trying to create a scheduled task. I am getting below mentioned error. I am using windows 7 x64 with VS2010 and my project targets .NET Framework 3.5. Please help as soon as possible as I am stuck rite now. Thanks in advance.

System.Runtime.InteropServices.COMException was unhandled by user code
   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)
   at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String Path, TaskDefinition definition)
   at NullVoidCreations.Janitor.Shell.Models.TaskModel.Create() in D:\Projects\Janitor\NullVoidCreations.Janitor.Shell\Models\TaskModel.cs:line 38
   at NullVoidCreations.Janitor.Shell.ViewModels.SettingsViewModel.ExecuteSaveSchedule(Object parameter) in D:\Projects\Janitor\NullVoidCreations.Janitor.Shell\ViewModels\SettingsViewModel.cs:line 350
   at NullVoidCreations.Janitor.Shared.Base.AsyncDelegateCommand.DoWork(Object sender, DoWorkEventArgs target) in D:\Projects\Janitor\NullVoidCreations.Janitor.Shared\Base\AsyncDelegateCommand.cs:line 63
   at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
Jan 18 at 3:41 PM
Given the error, this has to do with the StartBoundary setting on one of the triggers. Check to make sure it is before any EndBoundary setttings and has not been set to DateTime.MinTime. There are a few settings that are also interdependent. If you send the code for how you are setting the trigger(s), I can help you debug further.
Marked as answer by waliarubal on 1/18/2017 at 10:56 AM
Jan 18 at 5:32 PM
Below is a glimpse of method I am using to schedule tasks. You will see TaskModel which is just a wrapper to store schedule information. Do let me know where I have gone wrong. Look ahead to hearing from you very soon.

object ExecuteSaveSchedule(object parameter)
        var task = new TaskModel();
        task.Name = string.Format("{0}AutomaticSmartScan", SettingsManager.Instance.CodeName);
        if (IsScheduleDisabled)
            return task.Delete();

        task.ExecutablePath = SettingsManager.Instance.ExecutablePath;
        task.CommandLineArguments = string.Format("/{0} /{1}", CommandLineManager.CommandLineArgument.Silent, CommandLineManager.CommandLineArgument.SmartScan);

        var schedule = new DateTime(Date.Year, Date.Month, Date.Day, Time.Hour, Time.Minute, Time.Second);
        if (IsScheduleOnce)
            task.Schedule = new TimeTrigger(schedule);
            task.Schedule.EndBoundary = DateTime.MaxValue;
        else if (IsScheduleDaily)
            task.Schedule = new DailyTrigger();
            task.Schedule.StartBoundary = schedule;
            task.Schedule.EndBoundary = DateTime.MaxValue;
        else if (IsScheduleWeekly)
            DaysOfTheWeek days = DaysOfTheWeek.AllDays;
            for (short index = 0; index < WeekDays.Count; index++)
                if (!WeekDays[index])

                DaysOfTheWeek day = DaysOfTheWeek.AllDays;
                switch (index)
                    case 0:
                        day = DaysOfTheWeek.Sunday;

                    case 1:
                        day = DaysOfTheWeek.Monday;

                    case 2:
                        day = DaysOfTheWeek.Tuesday;

                    case 3:
                        day = DaysOfTheWeek.Wednesday;

                    case 4:
                        day = DaysOfTheWeek.Thursday;

                    case 5:
                        day = DaysOfTheWeek.Friday;

                    case 6:
                        day = DaysOfTheWeek.Saturday;

                if (days == DaysOfTheWeek.AllDays)
                    days = day;
                    days |= day;
            task.Schedule = new WeeklyTrigger(days);
            task.Schedule.StartBoundary = schedule;
            task.Schedule.EndBoundary = DateTime.MaxValue;

        var result = task.Create();
        if (result)
            Date = task.Schedule.StartBoundary;
            Time = task.Schedule.StartBoundary;
        return result;
Jan 18 at 6:56 PM
I figured out, date was an issue. I will send you a free license of software I am making. Just email me at
Jan 19 at 1:31 AM
Glad you figured it out. If you would please add in what you found to be the problem by editing your last message. I'd also remove your email as this is a public forum.