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

Weird exception

Topics: Errors, Examples
Feb 4, 2014 at 8:31 AM
Edited Feb 11, 2014 at 8:13 AM
I have just tried to run the example from this site in my asp.net application. Connections in task service are working:
using (TaskService ts = new TaskService())
            {
                // Create a new task definition and assign properties
                TaskDefinition td = ts.NewTask();
                td.RegistrationInfo.Description = "Does something";
                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 { DaysInterval = 2 });
                dt.Repetition.Duration = TimeSpan.FromHours(4);
                dt.Repetition.Interval = TimeSpan.FromHours(1);

                // Add a trigger that will fire every week on Friday
                td.Triggers.Add(new WeeklyTrigger
                {
                    StartBoundary = DateTime.Today + TimeSpan.FromHours(2),
                    DaysOfWeek = DaysOfTheWeek.Friday
                });

                // Add an action that will launch Notepad whenever the trigger fires
                td.Actions.Add(new ExecAction("cmd.exe", "c:\\test.log", null));

                // Register the task in the root folder
                const string taskName = "Test";
                ts.RootFolder.RegisterTaskDefinition(taskName, td);
            }
And in the last row strange exception has appeared:
System.Runtime.InteropServices.COMException: (57,4):Task:

Please, help!
Coordinator
Feb 5, 2014 at 2:43 PM
If you call
t.RegisterChanges();
instead of calling RegisterTaskDefnition on the last row, do you get the same error?
Feb 11, 2014 at 8:13 AM
It appears there is no way to create scheduled tasks from asp.net application
Coordinator
Feb 14, 2014 at 2:49 PM
There are a number of ways and a number of discussions in this forum that cover the topic. Please search and follow the answers there.
Marked as answer by dahall on 9/1/2015 at 10:10 AM