We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Primavera P6 no longer reading Project level Calendar information

.NET version 22.3 of Aspose.Tasks has changed the behavior of the Project.Get(Prj.Calendar) method.

For the attached sample schedule getting the Calendar from the project returns a null value and attempting to add new tasks to the project fail with a “Calendar cannot be null” error. In prior versions, the get returned the single calendar and adding tasks is successful.

        string fileName = @"C:\VGO Project Baseline Schedule.xer";
        Project m_Project = new Project(fileName);

        ChildTasksCollector m_coll = new ChildTasksCollector();
        TaskUtils.Apply(m_Project.RootTask, m_coll, 0);
        List<Aspose.Tasks.Task> Tasks = m_coll.Tasks;

        Console.WriteLine(m_Project.Get(Prj.Calendar) == null ? "Calendar is null" : m_Project.Get(Prj.Calendar).Name);

        Console.WriteLine("Calendar Count: {0}",m_Project.Calendars.Count);
        Console.WriteLine("Calendar: {0}", m_Project.Calendars.First().Name);

        Aspose.Tasks.Task m_CalcTask;// = null;
        m_CalcTask = m_Project.RootTask.Children.Add("InitialTask");
        m_CalcTask.Set(Tsk.Calendar, m_Project.Get(Prj.Calendar));
        m_CalcTask.Set(Tsk.IsManual, false);
        m_CalcTask.Set(Tsk.Start, new DateTime(2020, 3, 31, 8, 0, 0));
        m_CalcTask.Set(Tsk.Duration, m_Project.GetDuration(1, TimeUnitType.Day));

VGO Project Baseline Schedule.zip (154.5 KB)

Version22.3.jpg (155.9 KB)
Version22.2.jpg (49.4 KB)

I was able to reproduce the issue on v. 22.3.
I’ve checked your code using v. 22.4 and output is

Internal calender(30 days/month)
Calendar Count: 1
Calendar: Internal calender(30 days/month)

Could you check your scenario using v. 22.4 please ?

It does work with version 22.4. I’ll upgrade to that version. Thank you.