I tried to go back to the bare basics, and get your code to work.
I tried to amend it so that it would create a project from scratch, but couldn't get the following code to work. Any help would be appreciated (again!). Cheers, Steve
Dim license3 As Aspose.Tasks.License = New Aspose.Tasks.License
license3.SetLicense(HttpContext.Current.Server.MapPath("Aspose.Tasks.lic"))
Dim oProject As New Project
oProject.WorkFormat = TimeUnitType.Hour
oProject.MinutesPerDay = 60 * 8
Dim cal As Aspose.Tasks.Calendar = New Aspose.Tasks.Calendar()
cal.Name = "Calendar24x7"
Aspose.Tasks.Calendar.MakeStandardCalendar(cal)
'add working days monday through thursday with default timings
cal.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Monday))
cal.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Tuesday))
cal.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Wednesday))
cal.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Thursday))
cal.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Friday))
cal.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Saturday))
cal.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Sunday))
oProject.Calendars.Add(cal)
oProject.CalcCalendarUids()
Dim Task As New Task("New completed task.")
Task.Calendar = cal
Task.Uid = oProject.NextTaskUid
Task.Type = TaskType.FixedUnits
Task.Start = New DateTime(2010, 12, 15, 8, 0, 0)
Task.Duration = New TimeSpan(80, 0, 0)
Task.Finish = cal.GetFinishDateByStartAndWork(Task.Start, Task.Duration)
Task.DurationFormat = TimeUnitType.Day
Task.ActualStart = Task.Start
Task.ActualFinish = Task.Finish
Task.ActualDuration = Task.Duration
Task.PercentComplete = 100
Dim Resource As New Resource()
Resource.Name = "Employee"
Resource.Type = ResourceType.Work
Resource.Work = Task.Duration
Resource.ActualWork = Resource.Work
Resource.Uid = oProject.NextResourceUid
oProject.Resources.Add(Resource)
Dim ra As New ResourceAssignment()
ra.Uid = oProject.NextResourceAssignmentUid
ra.Task = Task
ra.Resource = Resource
ra.ActualWork = Resource.Work
ra.Work = Resource.Work
ra.Start = Task.Start
ra.Finish = Task.Finish
ra.Units = 1
ra.TimephasedDataFromTaskDuration(cal)
oProject.ResourceAssignments.Add(ra)
oProject.RootTask.Children.Add(Task)
oProject.CalcTaskIds()
oProject.CalcResourceIds()
oProject.CalcResourceAssignmentIds()
Dim prjWriter As New ProjectWriter()
Me.Response.ContentType = "application/vnd.ms-project"
Me.Response.AppendHeader("Content-Disposition", "attachment; filename=project.xml")
Me.Response.Flush()
Dim st As System.IO.Stream = Me.Response.OutputStream
prjWriter.Write(oProject, st, TasksDataFormat.XML)
Me.Response.End()