I'm not sure what is causing your error. I would change your code sample to:
Using D as New TaskEditDialog(ts.GetTask("\MyTasks\Task1"), True, True)
D.ShowDialog()
End Using
Let me know if that changes anything. I had tested this on 8.1. If you are seeing the error still, please post the result of the D.Task.Xml after calling the constructor (or Initialize) but before calling ShowDialog.