I wrote an c# console app which calls web service.
I needed to run this app for every night, so I decided to use this task scheduler as it seems a good one to do my job.
But I got an issue which says "Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. ..."
I read many articles described about same issue, but nothing is helpful.
For example,
```
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Does something";
td.Principal.Id = "any string";
td.Principal.GroupId = "NETWORK SERVICE";
td.Principal.RunLevel = TaskRunLevel.LUA;
td.Principal.LogonType = TaskLogonType.S4U;
ts.RootFolder.RegisterTaskDefinition(@"NetsuiteInvoiceGetTask", td);
```
My OS is Windows7 64bit.
Can anyone help me? Thanks.
Comments: ** Comment from web user: dahall **
I needed to run this app for every night, so I decided to use this task scheduler as it seems a good one to do my job.
But I got an issue which says "Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. ..."
I read many articles described about same issue, but nothing is helpful.
For example,
```
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Does something";
td.Principal.Id = "any string";
td.Principal.GroupId = "NETWORK SERVICE";
td.Principal.RunLevel = TaskRunLevel.LUA;
td.Principal.LogonType = TaskLogonType.S4U;
ts.RootFolder.RegisterTaskDefinition(@"NetsuiteInvoiceGetTask", td);
```
My OS is Windows7 64bit.
Can anyone help me? Thanks.
Comments: ** Comment from web user: dahall **
If the exception occurs on line 524, then it is happening with either "urls" or "originalUri" and not anything to do with task registration. Something else to be aware of, you need to connect to the TaskService using credentials that can create tasks. See [this link](https://taskscheduler.codeplex.com/wikipage?title=TaskSecurity&referringTitle=Documentation#remote) for information on connecting using a known account with permissions.