This project has moved and is read-only. For the latest updates, please go here.

Cannot register Task from WCF Service

Dec 8, 2011 at 9:54 PM

Hi,

I'm trying to register a task from a WCF Service running asp.net 4.0 but get the following error:

Message: (39,4):Task:

StackTrace:

   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 Utpl.Syllabus.Framework.Batch.WindowsScheduler.CreateTask(String name, String description, SchedulerOptions options) in ....   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)

Visual Studio says "check the error property", the error property is -2147216616, as far as I know this is not a valid HRESULT, so can't determine which is the cause of the error.

 

This is my code:

using (var taskService = new TaskService())
{
     TaskDefinition taskDefinition = taskService.NewTask();
     taskDefinition.RegistrationInfo.Description = description;

     taskDefinition.Triggers.Add(GetTrigger(options));
taskDefinition.Actions.Add(DetermineActionToExecute(options));

                taskService.RootFolder.RegisterTaskDefinition(
                    string.Format(@"{0}\{1}", "AppTasksFolder"  ,
                                  name), taskDefinition);
}

 

Any ideas?

 

My system:

Windows 7 Profession x64

ASP.net 4.0

Dec 9, 2011 at 5:24 PM

That is the error SCHED_E_INVALIDVALUE (0x80041318) - The task XML contains a value which is incorrectly formatted or out of range.

My guess is that you have a problem with a value in the the trigger or action.


Dec 14, 2011 at 6:09 PM

Hi,

Thanks for the reply.

What are the required permissions for the user to create Task?, I have created a unit test and everything works fine, however using the WCF Service I get the errors, so I'm assuming that is a permissions issue.

Dec 15, 2011 at 5:59 PM

Check the MSDN documentation for a full description on security.