The error is coming from the RegisterTaskDefinition native method. It likely has something to do with the settings for
To make the syntax simpler, try:
newTask
.To make the syntax simpler, try:
Dim tf = If(ts.GetFolder("X"), ts.RootFolder.CreateFolder("X")) tf.RegisterTaskDefinition("myTask", newTask)