I'm trying to create a schedule task with the Windows Task Scheduler in C#. It is failing when trying to register the task which is the following line of code:

IRegisteredTask regTask =...