Hi , I try create task only with end date. But get the exception The difference between start and finish date cannot be more than 50 years
var license = new License();
Stream licenseStream =
Assembly.GetExecutingAssembly().GetManifestResourceStream(
"Aspose_test_Solution.Aspose.Tasks.lic");
license.SetLicense(licenseStream);
var project = new Project();
var task = project.RootTask.Children.Add("Task without dates");
// we need have empty task without start date , end date and duration, just empty task
task.Set(Tsk.DurationText, string.Empty); // don't clean duration Why and how do it?
task.Set(Tsk.FinishText, string.Empty);
task.Set(Tsk.ActualFinish, DateTime.MinValue);
task.Set(Tsk.ActualStart, DateTime.MinValue);
task.Set(Tsk.StartText, string.Empty);
// we need have empty task without start date , end date and duration, just empty task
var endDate = new DateTime(2019,7,30);
task.Set(Tsk.ActualFinish, endDate); //<--- Exception 'The difference between start and finish date cannot be more than 50 years.'
I have observed the sample code shared by you and also the exception message. Actually, you are using MinDate as start and 2019-07-30 as end date. As evident from exception message the start and end date cannot have difference greater than 50 years. You need to please set appropriate start date to verify on your end.
Hello @LogicSoft
You can do it as follows by setting the project’s CalculationMode to Manual
var project = new Project() { CalculationMode = CalculationMode.Manual };
var task = project.RootTask.Children.Add("Task without dates");
// we need have empty task without start date , end date and duration, just empty task
task.Set(Tsk.DurationText, string.Empty); // don't clean duration Why and how do it?
task.Set(Tsk.FinishText, string.Empty);
task.Set(Tsk.ActualFinish, DateTime.MinValue);
task.Set(Tsk.ActualStart, DateTime.MinValue);
task.Set(Tsk.StartText, string.Empty);
// we need have empty task without start date , end date and duration, just empty task
var endDate = new DateTime(2019,7,30);
task.Set(Tsk.ActualFinish, endDate);
project.Save("out.xml", SaveFileFormat.XML);
But it does not make any sense to do that, because in this case you are getting a broken task. Hope by using my solution from this topic you won’t need this piece of code.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.