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

Free Support Forum - aspose.com

Generated Project xml file cannot be opened in MS Project


I have a very simple example to demonstrate the issue - please see attached Program.cs file.
The code generates a file called project.xml, which cannot be opened with MS Project for unknown reasons when using Aspose.Tasks version 6.4.0 (I think the issue is present in all version from 5.2.0 and up). The same code seems to be working with version 5.1.0.

Please advise.

Best Regards

Hi Kiril,

Thank you for contacting Aspose support team.

Aspose.Tasks has simplified the process of project file creation and now there is no need to add root task, calendar, resource etc. Could you please try the following simple code which creates valid xml files? You may update it according to your requirements and let us know your feedback.

Project prj = new Project();
prj.StartDate = DateTime.Parse(“18-Aug-2009 8:00 AM”);
Task tsk1 = prj.AddTask(“Task1”);
tsk1.ConstraintType = ConstraintType.StartNoEarlierThan;
tsk1.Start = DateTime.Parse(“18-Aug-2009 8:00 AM”);
Task tsk2 = prj.AddTask(“Task2”);
tsk2.ConstraintType = ConstraintType.StartNoEarlierThan;
tsk2.Start = DateTime.Parse(“19-Aug-2009 8:00 AM”);
Resource res1 = prj.AddResource(“Resource1”);
ResourceAssignment ra1 = prj.AddResourceAssignment(tsk1, res1);
ResourceAssignment ra2 = prj.AddResourceAssignment(tsk2, res1);

//Save the Project
prj.Save(“Project.Xml”, Aspose.Tasks.Saving.SaveFileFormat.XML);

Hi Kashif,

Thanks for your promptly response.
The issue with my original example seems to be with the ExtendedAttributeDefinition added to the project and the ExtendedAttribute added to each task. If I remove them - everything is ok. Can you please post an example how to use ExtendedAttributeDefinition and ExtendedAttribute?

Best Regards

Hi Kiril,

We are sorry for the delayed response. We are working on this issue and will share our findings shortly. Thank you for your patience in this regard.

Hi Kiril,

Following is a sample code which demonstrates the usage of text ExtendedAttribute and ExtendedAttributeDefinition. Could you please give it a try and let us know your feedback?

Project prj = new Project();
ExtendedAttributeDefinition ead = default(ExtendedAttributeDefinition);
ExtendedAttribute ea = default(ExtendedAttribute);
Task task1 = prj.AddTask(“Test Task”);

//add extended attribute definition
ead = new ExtendedAttributeDefinition();
ead.FieldName = “Text1”;
ead.Alias = “Description”;
ead.FieldId = Convert.ToInt32(ExtendedAttributeTask.Text1).ToString();
prj.ExtendedAttributes = new List();

foreach (Task task in prj.RootTask.Children)
task.ExtendedAttribute = new List();
ea = new ExtendedAttribute();
ea.FieldId = ead.FieldId;
ea.Value = string.Format(“Description of ‘{0}’.”, task.Name);

prj.Save(“Project.xml”, Aspose.Tasks.Saving.SaveFileFormat.XML);