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

Free Support Forum - aspose.com

Task Assignment count incorrect

Dear Team,
When I try to read assignment count for each task, I get the count as 1 even though I don’t have any assignment for that particular task.
I see this problem coming up for any outline level 1 and outline level 2 tasks.
Sample code :
TaskCollection otskCol = oProjMpp.RootTask.Children;
otskCol.ToList().ForEach(item => {
int? iAssignmentcount = item?.Assignments?.Count;
Console.WriteLine($"\tAssisgnment Count : {iAssignmentcount}");
if ( item?.Children?.Count > 0 ) {
TaskCollection oSubTaskCol = item?.Children;
oSubTaskCol.ToList().ForEach(item1 => {
iAssignmentcount = item1?.Assignments?.Count;
Console.WriteLine($"\tAssisgnment Count : {iAssignmentcount}");

Am using version Asponse.Task 17.8.0.


Thank you for contacting Aspose support team.

A project file “Project1.xml” is created using Microsoft Project (MSP) 2010 by adding only tasks (no resource, no assignment) as shown in the attached image MSP2010File.png.

This file is used to display assignments count as shown in the following sample code:

static void GetAssignmentCount(Task tsk)
    Console.WriteLine(tsk.Get(Tsk.Name) + "," +  tsk.Assignments.Count);
    if(tsk.Children.Count() > 0)
        foreach(var tsk1 in tsk.Children)
static void Tasks_165621()
    Project oProjMpp = new Project(@"Project1.xml");
    TaskCollection otskCol = oProjMpp.RootTask.Children;
    foreach (var task in otskCol)

Following is the output of the program:

Task 1, 0
Task 2, 1
Task 3, 0
Task 4, 0
Task 5, 1

This shows that task 2 and 5 has one assignment each whereas in the actual project file using MSP 2010, no assignment was done.

Now if we open the XML file created by MSP 2010, we can observe that Microsoft project has itself added assignments as can be seen between tags ASSIGNMENTS. This is default behavior of MSP that it adds assignment to the child tasks under a summary task automatically which are actually read by Aspose.Tasks. Hence this does not seem to be a bug in Aspose.Tasks.

You may please convert your project file into XML and open it in some editor like notepad. You will observe these assignments there. If you don’t find any assignment in project, and still Aspose.Tasks is reading it, please share your sample project file with is. We will analyze it and share the feedback.

MSP2010File.png (6.7 KB)
ProgramOutput.png (921 Bytes)
Project1.zip (2.8 KB)

Thank You team, for the quick reply.
I do observe this weird behavior for my MPP file by converting to xml format.


So, it seems that the issue is not with Aspose.Tasks API. Please let us know if we can be of any additional help to you in this regard.