Resource Name not saving to mpp file

Hi,


I have followed the example in the Aspose.Tasks help file that creates tasks, resources and assignments and then writes them to a project. This works fine when I write to an xml file but when I update an empty mpp file the resource names are not displayed within MS Project.

The code below exhibits the problem. Does anyone have any idea why the resource names are not visible when saved as an mpp file?

Thanks, Vincent

//
static void Main(string[] args)
{

License license = new License();
license.SetLicense(“Aspose.Tasks.lic”);

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

//Define Resources
Resource rec = new Resource();
Resource rec1 = new Resource(“Res1”);
rec1.Type = ResourceType.Work;
Resource rec2 = new Resource(“Res2”);
rec2.Type = ResourceType.Material;
prj.Resources.Add(rec);
prj.Resources.Add(rec1);
prj.Resources.Add(rec2);

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

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

//define assignment
ResourceAssignment ra1 = new ResourceAssignment(tsk1, rec1);
ResourceAssignment ra2 = new ResourceAssignment(tsk2, rec2);
prj.ResourceAssignments.Add(ra1);
prj.ResourceAssignments.Add(ra2);

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

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

//write the stream in mpp format
prjWriter.Write(prj, “c:\project5.mpp”, TasksDataFormat.MPP);

//write the stream in XML format
prjWriter.Write(prj, “c:\project5.xml”, TasksDataFormat.XML);
}
//

Hi Vincent,


Thanks for writing to Aspose.Tasks support team.

I have tried the above mentioned code using Aspose.Tasks for .NET 4.9.0. I used Microsoft Project 2010 to open both the output MPP/XML files and afraid to inform that resource names are there in the saved MPP file. The empty template project file was generated through MSP 2010.

Could you please test this scenario with the above mentioned environment and let us know your feedback.

Hi Kashif,


Thanks for your quick response. It seems the template project file I was using was in MSP 2003 format! So, using a 2010 format as you did, solved the problem.

Thanks,

Vincent