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

Free Support Forum - aspose.com

An import error occured

Dear Team,

I have just got the aspose task tool. i just executed the sample given the Featured demo in C#. I am getting this error. Please guide me to resolve this error.

This message was posted using Page2Forum (attachment) from Our Blog - Aspose.Tasks for .NET

Are you using Project 2007? The problem occurs with it and we are trying to fix it. Please see this thread.

No. I am working with MS Project 2003. But in the same machine i can open the demo file in the aspose website. But when i trying the sample provided by aspose component in my local machine i am getting this error. Please reply asap.

here by i am pasting the code which i have used to generate an mpx file. and also the generated file is also attached here for you reference. Please guide me asap.

MPXFile file = new MPXFile();

//After that change project's default options to automatic generation of Calendar's,

//Task's and Resource's id numbers, outline levels and WBS labels:

file.AutoCalendarUniqueID = true;

file.AutoTaskID = true;

file.AutoTaskUniqueID = true;

file.AutoResourceID = true;

file.AutoResourceUniqueID = true;

file.AutoOutlineLevel = true;

file.AutoOutlineNumber = true;

file.AutoWBS = true;

//Next create a default calendar.

//In such calendar default workdays are Monday - Friday and worktime is 8:00 – 12:00,


MPXHeader prj = file.Project;

//After that set project title and Start date

prj.StartDate = new System.DateTime(2000, 1, 1);

prj.Title = "sample";

//Now add 2 resources to project:

Resource resource1 = file.AddResource();

resource1.Name = "Resource1";

resource1.AvailableFrom = new System.DateTime(2000, 1, 13);

resource1.AvailableTo = new System.DateTime(2000, 1, 16);

Resource resource2 = file.AddResource();

resource2.Name = "Resource2";

resource2.AvailableFrom = new System.DateTime(2000, 1, 13);

resource2.AvailableTo = new System.DateTime(2000, 1, 30);

//Next step is adding a Summary Task. Every project has such task from which others are inherited. It is hidden by default.

Task task1 = file.AddTask();

task1.Name = "Summary Task";

//Next we will create a first task:

Task task2 = task1.AddTask();

task2.Name = "First Sub Task";

task2.Duration = new Duration(10, TimeUnit.Days);

task2.Start = new System.DateTime(2000, 1, 1);

//We'll set this task up as being 50% complete.

//If we have no resource assignments for this task,

//this is enough information for MS Project.

//If we do have resource assignments, the assignment record needs to contain the

//corresponding work and actual work fields set to the correct value1s in order

//for MS project to mark the task as complete or partially complete.

task2.PercentComplete = 50.0;

task2.ActualStart = new System.DateTime(2000, 1, 1);

//And now a second task:

Task task3 = task1.AddTask();

task3.Name = "Second Sub Task";

task3.Start = new System.DateTime(2000, 1, 11);

task3.Duration = new Duration(10, TimeUnit.Days);

//We'll link these tasks so one is started after another:

Relation rel1 = task3.AddPredecessor(task2);

rel1.Type = TaskLinkType.FinishToStart;

//After that add a milestone and link it with the second task:

Task milestone1 = task1.AddTask();

milestone1.Name = "Milestone";

milestone1.Start = new System.DateTime(2000, 1, 21);

milestone1.Duration = new Duration(0, TimeUnit.Days);

Relation rel2 = milestone1.AddPredecessor(task3);

rel2.Type = TaskLinkType.FinishToStart;

//Now assign resources to tasks:

ResourceAssignment assignment1 = task2.AddResourceAssignment(resource1);

ResourceAssignment assignment2 = task3.AddResourceAssignment(resource2);

//As the first task is partially complete, and we are adding a resource assignment,

//we must set the work and actual work fields in the assignment to appropriate value1s,

//or MS Project won't recognize the task as being complete or partially complete:

assignment1.Work = new Duration(80, TimeUnit.Hours);

assignment1.ActualWork = new Duration(40, TimeUnit.Hours);

//Creation of project is completed and now we can send it to our browser:

this.Response.ContentType = "application/vnd.ms-project";

this.Response.AppendHeader("Content-Disposition", "attachment; filename=project.mpx");


System.IO.Stream st = this.Response.OutputStream;