Click here to Skip to main content
13,045,790 members (45,515 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have written the following code .

                using (TaskService ts = new TaskService())
                    // Create a new task definition and assign properties
                    TaskDefinition td = ts.NewTask();
                    td.RegistrationInfo.Description = "working with network failOver";
                    td.Principal.LogonType = TaskLogonType.InteractiveToken;
                    // Add a trigger that will fire the task at this time every other day
                    DailyTrigger dt = (DailyTrigger)td.Triggers.Add(new DailyTrigger(24));
                    dt.Repetition.Duration = TimeSpan.FromMinutes(5);
                    dt.Repetition.Interval = TimeSpan.FromMinutes(2);
                    // Add a trigger that will fire every week on FridayDaysOfTheWeek.Friday
                    td.Triggers.Add(new WeeklyTrigger(DaysOfTheWeek.AllDays, 1));//  + TimeSpan.FromHours(2), DaysOfWeek = DaysOfTheWeek.Friday });               
                    td.Actions.Add(new ExecAction(AppDomain.CurrentDomain.BaseDirectory + @"Data.aspx\shedularEXE\HandlingConnFailover", "c:\\test.log", null));
                    // Register the task in the root folder
                    const string taskName = "Sync All Database";
                    ts.RootFolder.RegisterTaskDefinition(taskName, td);
                    // Retrieve the task, change the trigger and re-register it
                    Task t = ts.GetTask(taskName);
                    td = t.Definition;
                    td.Triggers[0].StartBoundary = DateTime.Now.AddMinutes(2);//.Today;//+ TimeSpan.FromDays(7);
                    ts.RootFolder.RegisterTaskDefinition(taskName, td);
                    // Remove the task we just created
                    // ts.RootFolder.DeleteTask(taskName);
            catch (Exception ee)
                string s = ee.Message;

but i am getting an exception in line
ts.RootFolder.RegisterTaskDefinition(taskName, td)
the message is as ... "(63,4):Task:"
Please suggest me what i need to do ?
Posted 6-May-13 18:29pm
Updated 6-May-13 18:38pm
It does not look like a comprehensive exception information...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 7 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100