Click here to Skip to main content
15,867,939 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have written the following code .

C#
try
            {
                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
C#
ts.RootFolder.RegisterTaskDefinition(taskName, td)
;
the message is as ... "(63,4):Task:"
Please suggest me what i need to do ?
Posted
Updated 6-May-13 18:38pm
v4
Comments
Sergey Alexandrovich Kryukov 7-May-13 1:54am    
It does not look like a comprehensive exception information...
—SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900