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();
}
/*********************************************************************/