Updated mpp file has no child tasks

Hi,


I am having an issue where I am writing a project to an mpp file. The updated mpp file will open in MSP 2010 but the tasks that I have added from code appear as indented tasks below a task with the name of the original template file! (See the attached screen shot) Collapsing then expanding this “extra” task from within MSP causes it to vanish!

If I read the created file with Aspose.Tasks the loaded project has no children under the RootTask.

I have attached the MS Project 2010 template file that I am using.

Can you let me know if am I doing something wrong please?

Thanks.

The code below exhibits the problem:

/*********************************************************************/
static void Main()
{
var license = new License();
license.SetLicense(“Aspose.Tasks.lic”);

//create a project instance
var projectReader = new ProjectReader();
Project prj = projectReader.Read(“project.mpp”);

//define Tasks
var rootTsk = new Task();
var tsk1 = new Task(“Tsk1”);
var tsk2 = new Task(“Tsk2”);

//add tasks
rootTsk.Children.Add(tsk1);
rootTsk.Children.Add(tsk2);
prj.RootTask = rootTsk;

//perform recalculations
prj.CalcResourceIds();
prj.CalcResourceUids();
prj.CalcResourceFields();
prj.CalcTaskIds();
prj.CalcTaskUids();
prj.CalcResourceAssignmentIds();
prj.CalcResourceAssignmentUids();

//create a project writer instance
var prjWriter = new ProjectWriter();

//write the stream in mpp format
prjWriter.Write(prj, “project5.mpp”, TasksDataFormat.MPP);
//read updated mpp
prj = projectReader.Read(“project5.mpp”);

//no child tasks!
Console.Write(prj.RootTask.Children.Count);
Console.ReadKey();
}
/*********************************************************************/

Hi Vincent,


Thank you for writing to us.

I have checked your sample code alongwith the sample MPP template file attached. This seems to be an issue with the Aspose.Tasks handling of MPP files. I have logged it in our bug tracking system as TASKS-33276 for further investigation by the development team. Once the issue is resolved, we’ll update you via this thread. Your patience till then is much appreciated.

The issues you have found earlier (filed as TASKS-33276) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi,
The problem still exists in 5.1
Can you please give an estimate of when it’s going to be fixed?

Regards,
Pavel

Hi Pavel,


I have tested the above mentioned code using latest version of Aspose.Tasks for .NET 5.1.0 and found that no parent task was added before the actual tasks added in the program. MS project 2010 is used to view the updated file.

The second issue of zero children tasks under root task can be resolved by adding prj.UpdateReferences() before writing the project to the disc. Please modify your code as given below:

//perform recalculations
prj.CalcResourceIds();
prj.CalcResourceUids();
prj.CalcResourceFields();
prj.CalcTaskIds();
prj.CalcTaskUids();
prj.CalcResourceAssignmentIds();
prj.CalcResourceAssignmentUids();

//ADD THIS LINE
prj.UpdateReferences();

Please feel free to write us back if you have any other query in this regard.

Thanks Kashif,
that worked fine.
Regards,
Pavel

Hi Pavel,


We are glad to know that your issue is resolved.

Please feel free to write us back if you have any other query related to Aspose.Tasks.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.