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

Free Support Forum - aspose.com

Fixed duration task error


I am having a problem with tasks duration display.

The problem happens when I define a task as ‘fixed duration’ and it doesn’t have any assignment: just a single fixed duration task.
When I open the xml in MS project, the grantt diagram show a one day duration task (shown in the picture). But when I don’t define my task type, its duration is well displayed! (the other picture)

I would like to know why and how to get a normal displayed task?

In my project, I have to use the project.RootTask.Children.Add method and not the addTasks method.


Hi Katherine,

Thank you for writing to Aspose support.

I have analyzed your requirements and observed that if we create such a task with MSP, it generates a ResourceAssignment for this task. When we use Project.AddTask() method it performs all these tasks automatically, however if you want to use Project.RootTask.Children.Add() function, please give a try to the following sample code and let us know your feedback.

Project project = new Project();
project.StartDate = new DateTime(2010, 5, 1);

Aspose.Tasks.Task taskFixedDuration = new Aspose.Tasks.Task(“Fixed duration task”);
taskFixedDuration.Type = TaskType.FixedDuration;
taskFixedDuration.Start = new DateTime(2010, 5, 24);
taskFixedDuration.ConstraintDate = taskFixedDuration.Start;
taskFixedDuration.ConstraintType = ConstraintType.MustStartOn;
taskFixedDuration.Duration = new TimeSpan(24, 0, 0);
taskFixedDuration.DurationFormat = TimeUnitType.Day;

ResourceAssignment asmt1 = new ResourceAssignment(taskFixedDuration, null);
asmt1.Start = new DateTime(2010, 5, 24);
asmt1.RemainingWork = new TimeSpan(24, 0, 0);

project.Save(@“D:\Aspose\Issues\TASK\DotNet\588698\project24hours.xml”, SaveFileFormat.XML);