Free Support Forum - aspose.com

The example in the wiki does not work

i am trying the example in the wiki for creating tasks and i get an error when opening the file

MPXFile file = new MPXFile();
Aspose.Tasks.Task task1 = file.AddTask();
task1.Name = "Summary Task";
Aspose.Tasks.Task task2 = task1.AddTask();
task2.Name = "First Sub Task";
task2.Duration = new Duration(10, TimeUnit.Days);
task2.Start = new System.DateTime(2003, 1, 1);
Aspose.Tasks.Task task3 = task1.AddTask();
task3.Name = "Second Sub Task";
task3.Duration = new Duration(15, TimeUnit.Days);

then i just output the file to a response filestream as test.mpx to open the file and project gives this error

No calculations can be performed now.

There is a circular relationship in task 3 Summary of Task of "test[2]". The successors of this task refer back to this task or its predecessors, causing a circular reference.

when i continue all 3 tasks are seperate

if i include this code

Aspose.Tasks.Relation rel1 = task3.AddPredecessor(task2);
rel1.Type = TaskLinkType.FinishToStart;

i get this error as well as the previous one

An import error occurred.

Check row 1 column 5.

If you want to link the two tasks, outdent the subtask to a summary task, and then link them.

I am using Project 2003.

Examples in the Wiki can’t be used as a separate applications.
They are just short extracts which show how to add task or resource or something else.

There is should be also some preparation work before creating tasks.
For example you should set parameters of project, start/finish date and some more properties.
For better example please check our MPXCreate demo.

Where can i download the demo?

alcrus:
Examples in the Wiki can't be used as a separate applications.
They are just short extracts which show how to add task or resource or something else.

There is should be also some preparation work before creating tasks.
For example you should set parameters of project, start/finish date and some more properties.
For better example please check our MPXCreate demo.

where can i find the MPXCreate demo source

All demos were installed together with Aspose.Tasks.
You can find it in the \Program Files\Aspose\Aspose.Tasks\Demos folder.