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
Unfortunately this is a bug. If you ensure you have the task pane open when you run this code, it should succeed.
I have added an issue to our backlog to fix this for the next release.
Sorry for the inconvenience.