Adding task is giving exception

hey,
i have some issue adding some tasks, i have created this small console application to replicate my issue,

2 scenarios are there:

Adding Task Directly to project:
static void checkLoopProjectAdd()
{try{
var project = new Project();
project.StartDate = DateTime.Now; project.Name = “ExampleMpp”;
project.DefaultStandardRate = 15; project.Title = “ExampleMpp”;
Resource resc = new Resource(“Biswajeet”);
resc.Id = 22;
project.Resources.Add(resc);
var resource = project.Resources.FirstOrDefault();

Aspose.Tasks.Task task = project.AddTask(“Task”);
Aspose.Tasks.Task task11 = new Aspose.Tasks.Task(“Task11”);
task.Children.Add(task11);
Aspose.Tasks.Task task12 = new Aspose.Tasks.Task(“Task12”);
task.Children.Add(task12);
Aspose.Tasks.Task task2 = project.AddTask(“Task1231”);//Here exception will generate
Aspose.Tasks.Task task21 = new Aspose.Tasks.Task(“Task21”);
task2.Children.Add(task21);
Aspose.Tasks.Task task22 = new Aspose.Tasks.Task(“Task22”);
task2.Children.Add(task22);
}Catch(Exception ex){}
}
This will give Exception as ParentTask is Null , Project references need to be updated

Adding Task to another task in project:
static void checkLoopProjectAdd()
{try{
Task mainTask = project.AddTask(“Main Above Task”);

Task task1=new Task(“Task1”);
mainTask.Children.Add(task1);
onlyToAddInternalTask(task1, ref project,“Task11”);

Task task2 = new Task(“Task2”);
mainTask.Children.Add(task2);
onlyToAddInternalTask(task2, ref project, “Task21”);
}Catch(Exception ex)}
}
static void onlyToAddInternalTask(Task parentTask, ref Project project,string taskName)
{
var resource = project.Resources.FirstOrDefault();
Task task11 = new Task(taskName);
parentTask.Children.Add(task11);
Aspose.Tasks.ResourceAssignment assignment11 = project.AddResourceAssignment(task11, resource);//Here the exception will generate
}

in 1st scenario i can add resource assignment but not in the second scenario

i would like you to look in this immediately
Thank You

Hi Biswajeet,

Thank you for writing to Aspose support team.

I would like to share with you that we have revamped the Aspose.Tasks API and the legacy API is no more supported. Please refer to our online Migration article for converting your existing code to the revamped API code sample. I have converted one of your sample code to the new API and it works fine. Please try it at your end and share your feedback with us.

Sample Code:

Project project = new Project();

project.Set(Prj.StartDate, DateTime.Now);

project.Set(Prj.Name, "ExampleMpp");

project.Set(Prj.DefaultStandardRate, 15);

project.Set(Prj.Title, "ExampleMpp");

Resource rsc = project.Resources.Add("Biswajeet");

Task task = project.RootTask.Children.Add("Task");

Task task11 = task.Children.Add("Task11");

Task task12 = task.Children.Add("Task12");

Task task2 = project.RootTask.Children.Add("Task12");

Task task21 = task2.Children.Add("Task21");

Task task22 = task2.Children.Add("Task22");