Hi, I am having the error "Null Reference Exception" on the method Recalculate().
The error occur when I use the duration greater than 80 and the unit of the resource of 0.0223.
In the example above if I use 80 as duration it owrks fine, if I use 81 I get the error.
Best Regards,
Andre Makoski
Here is the example code and the Stack Trace:
private static void CreateFile(string fileName, string saveFileName)
{
Project project = new Project();
project.CalculationMode = CalculationMode.Manual;
Task Task1 = project.RootTask.Children.Add();
SetTaskData(Task1, 1, "001", false, ConstraintType.AsSoonAsPossible);
Task Task2 = Task1.Children.Add();
SetTaskData(Task2, 2, "001.01", true, ConstraintType.StartNoEarlierThan);
Resource rsc1 = project.Resources.Add("Resource 1");
rsc1.Set(Rsc.Code, "ISM");
rsc1.Set(Rsc.Name, "Resource 1");
rsc1.Set(Rsc.Type, ResourceType.Material);
project.ResourceAssignments.Add(Task2, rsc1, 0.0223);
project.Recalculate();
project.Save(saveFileName, Aspose.Tasks.Saving.SaveFileFormat.XML);
}
private static void SetTaskData(Task task, Double duracao, string wbs, bool manual, ConstraintType tipo)
{
task.Set(Tsk.Name, "Tarefa " + duracao.ToString());
task.Set(Tsk.WBS, wbs);
task.Set(Tsk.Cost, 1);
task.Set(Tsk.IsManual, manual);
task.Set(Tsk.Type, TaskType.FixedDuration);
task.Set(Tsk.DurationFormat, TimeUnitType.Day);
task.Set(Tsk.IsCritical, true);
task.Set(Tsk.IsActive, true);
task.Set(Tsk.IsMilestone, false);
task.Set(Tsk.ConstraintType, tipo);
DateTime start = new DateTime(2015, 1, 1);
DateTime finish = new DateTime(2015, 4, 23);
task.Set(Tsk.Start, start);
task.Set(Tsk.Finish, finish);
task.Set(Tsk.Duration, task.ParentProject.GetDuration(81, TimeUnitType.Day));
task.Set(Tsk.EarlyStart, start);
task.Set(Tsk.EarlyFinish, finish);
task.Set(Tsk.LateStart, start);
task.Set(Tsk.LateFinish, finish);
}
StackTrace:
em . (SplitPartCollection )
em . (DateTime , SplitPartCollection )
em . (DateTime )
em Aspose.Tasks.ResourceAssignment. (DateTime )
em Aspose.Tasks.Task. ()
em . ()
em . ()
em Aspose.Tasks.Task. ()
em Aspose.Tasks.Project.Recalculate()
em TesteProject.Form1.CreateFile(String fileName, String saveFileName) na c:\users\andre.makoski\documents\visual studio 2015\Projects\TesteProject\TesteProject\Form1.cs:linha 44
em TesteProject.Form1.button1_Click(Object sender, EventArgs e) na c:\users\andre.makoski\documents\visual studio 2015\Projects\TesteProject\TesteProject\Form1.cs:linha 23
em System.Windows.Forms.Control.OnClick(EventArgs e)
em System.Windows.Forms.Button.OnClick(EventArgs e)
em System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
em System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
em System.Windows.Forms.Control.WndProc(Message& m)
em System.Windows.Forms.ButtonBase.WndProc(Message& m)
em System.Windows.Forms.Button.WndProc(Message& m)
em System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
em System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
em System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
em System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
em System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
em System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
em System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
em System.Windows.Forms.Application.Run(Form mainForm)
em TesteProject.Program.Main() na c:\users\andre.makoski\documents\visual studio 2015\Projects\TesteProject\TesteProject\Program.cs:linha 19
em System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
em System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
em System.Threading.ThreadHelper.ThreadStart_Context(Object state)
em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
em System.Threading.ThreadHelper.ThreadStart()