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: richardk1031 **
Thanks for your post, but still doesn't work.
I tested 2 cases:
1) This doesn't run task.
```
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Does something";
ts.RootFolder.RegisterTaskDefinition("TaskName", taskDefinition,
TaskCreation.CreateOrUpdate, "SYSTEM", null,
TaskLogonType.ServiceAccount);
```
2) System.NullReferenceException
```
TaskDefinition td = ts.NewTask();
td.Principal.RunLevel = TaskRunLevel.Highest;
// Set trigger and action and other properties...
ts.RootFolder.RegisterTaskDefinition("Test", td);
```
My console app uses Netsuite webservice and taskeng.exe says that issue occurs in line 524.
(Screenshot attached)
```
522 System.Uri originalUri = new System.Uri(this.Url);
523 DataCenterUrls urls = getDataCenterUrls(account).dataCenterUrls;
524 Uri dataCenterUri = new Uri(urls.webservicesDomain + originalUri.PathAndQuery);
525 this.Url = dataCenterUri.ToString();
```
__Here__
this.Url = {https://webservices.netsuite.com/services/NetSuitePort_2013_2}
urls.webservicesDomain = "https://webservices.na1.netsuite.com"
originalUri.PathAndQuery = "/services/NetSuitePort_2013_2"
I think to try with
ts.RootFolder.RegisterTaskDefinition("TaskName", taskDefinition,
TaskCreation.CreateOrUpdate, "userDomain\\userName", "userPassword",
TaskLogonType.Password)
But don't know how to give parameters - "userDomain\\userName", "userPassword".
Would you help?