AnsweredAssumed Answered

Strange behavior when working with tasks in ArcGIS Pro and C#

Question asked by carstena@geoinfo on Aug 9, 2018
Latest reply on Aug 13, 2018 by carstena@geoinfo

Hi.

 

I've noticed something strange when developing a C# add-in for ArcGIS Pro.

 

I've created one task item with two task "inside".

I want to iterate through the list of tasks, like so:

 

var taskItem = Project.Current.GetItems<TaskProjectItem>().FirstOrDefault();

TaskItemInfo taskItemInfo = taskItem.GetTaskItemInfo(); // <-- This line is throwing the NullReferenceException

IEnumerable<TaskInfo> taskInfos = taskItemInfo.GetTasks();

foreach (TaskInfo taskInfo in taskInfos)
{

   // do something
}

 

But the 2nd line is throwing an exception. I don't understand why. I've actually taken the code from ArcGIS Pro 2.2 API Reference Guide with the same result. I don't get it. 

 

Any help would be greatly appreciated

Outcomes