Class TaskValidationException

TaskValidationException class

Represents an exception which is thrown when errors are found in project’s tasks after recalculation.

public class TaskValidationException : RecalculationValidationException

Properties

NameDescription
Task { get; }Gets the task which caused the exception.

Examples

Shows on what conditions <see cref=“TaskValidationException” /> exception can be thrown.

try
{
    var project = new Project { CalculationMode = CalculationMode.None };
    var task = project.RootTask.Children.Add("Task");

    // accidentally set incorrect dates
    task.Set(Tsk.Start, new DateTime(2017, 6, 19, 8, 0, 0));
    task.Set(Tsk.Duration, project.GetDuration(1));
    task.Set(Tsk.Finish, new DateTime(2017, 6, 18, 17, 0, 0));

    // run project recalculation with a flag to run validation   
    project.Recalculate(true);
}
catch (TaskValidationException ex)
{
    Console.WriteLine(ex.Message);
}

See Also