In our solution, export mpp files has no project calender

We encountered this issue in our project, please help us investigate it.

  1. Our project has a C# dual-framework architecture.

  2. When using Aspose.Task to export MPP files, we found that the exported content does not include the project calendar.

  3. However, when creating a separate project and running the same code, the exported MPP file does include the project calendar.
    Please help us locate the specific issue with the code provided below.

         var project = new Project();
         project.CalculationMode = CalculationMode.None;
         project.WorkFormat = TimeUnitType.Day;
         project.NewTasksAreManual = false;//新任务模式
    
         project.StartDate = new DateTime(2022, 5, 27);
         project.MinutesPerDay = 480;
    
         //设置日历
         var calendar = project.Calendar;
         calendar.WeekDays.Clear();
         calendar.Exceptions.Clear();
         //Calendar.MakeStandardCalendar(calendar);
         calendar.Name = "默认日历";
    
         var sunday = new WeekDay(DayType.Sunday);
         sunday.DayWorking = false;
         calendar.WeekDays.Add(sunday);
    
         var monday = new WeekDay(DayType.Monday);
         //WeekDay.SetDefaultWorkingTime(monday);
         monday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 8, 0, 0), new DateTime(2023, 1, 1, 12, 0, 0)));
         monday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 13, 0, 0), new DateTime(2023, 1, 1, 17, 0, 0)));
         calendar.WeekDays.Add(monday);
    
         var tuesday = new WeekDay(DayType.Tuesday);
         //WeekDay.SetDefaultWorkingTime(tuesday);
         tuesday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 8, 0, 0), new DateTime(2023, 1, 1, 12, 0, 0)));
         tuesday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 13, 0, 0), new DateTime(2023, 1, 1, 17, 0, 0)));
         calendar.WeekDays.Add(tuesday);
    
         var wednesday = new WeekDay(DayType.Wednesday);
         //WeekDay.SetDefaultWorkingTime(wednesday);
         wednesday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 8, 0, 0), new DateTime(2023, 1, 1, 12, 0, 0)));
         wednesday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 13, 0, 0), new DateTime(2023, 1, 1, 17, 0, 0)));
         calendar.WeekDays.Add(wednesday);
    
         var thursday = new WeekDay(DayType.Thursday);
         //WeekDay.SetDefaultWorkingTime(thursday);
         thursday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 8, 0, 0), new DateTime(2023, 1, 1, 12, 0, 0)));
         thursday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 13, 0, 0), new DateTime(2023, 1, 1, 17, 0, 0)));
         calendar.WeekDays.Add(thursday);
    
         var friday = new WeekDay(DayType.Friday);
         //WeekDay.SetDefaultWorkingTime(friday);
         friday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 8, 0, 0), new DateTime(2023, 1, 1, 12, 0, 0)));
         friday.WorkingTimes.Add(new WorkingTime(new DateTime(2023, 1, 1, 13, 0, 0), new DateTime(2023, 1, 1, 17, 0, 0)));
         calendar.WeekDays.Add(friday);
    
         var saturday = new WeekDay(DayType.Saturday);
         saturday.DayWorking = false;
         calendar.WeekDays.Add(saturday);
    
         //特殊日历
         //var calendar = project.Calendars.Add("Calendar1");
         var exception = new CalendarException();
         //exception.Name = "New Calendar Exception";
         exception.EnteredByOccurrences = false;
         exception.FromDate = new DateTime(2022, 1, 31, 0, 0, 0);
         exception.ToDate = new DateTime(2022, 2, 6, 23, 59, 59);
         exception.Type = CalendarExceptionType.Daily;
         //exception.Month = Month.December;
         exception.DayWorking = false;
         calendar.Exceptions.Add(exception);
    
         var exception2 = new CalendarException();
         //exception2.Name = "New Calendar Exception";
         exception2.EnteredByOccurrences = false;
         exception2.FromDate = new DateTime(2021, 12, 31, 0, 0, 0);
         exception2.ToDate = new DateTime(2022, 1, 2, 23, 59, 59);
         exception2.Type = CalendarExceptionType.Daily;
         //exception2.Month = Month.December;
         exception2.DayWorking = false;
         calendar.Exceptions.Add(exception2);
         project.CalculationMode = CalculationMode.Automatic;
    
    
         project.Save("C:\\InforCenterData\\Temp\\Test我的测试计划" + DateTime.Now.ToString("MMddHHmmss") + ".mpp");

@Jiangqiming,
which version of Aspose.Tasks do you use?

The lastest version 23.4

I see that the resulting project contains the modified project calendar, but Monday-Friday are marked as non-working. You should set property DayWorking for these days:

monday.DayWorking = true;
tuesday.DayWorking = true;
etc.

I will create an improvement in our issue tracking system to make this scenario more user-friendly.

If your have another problem, feel free to describe it.
.

I understand the specific reason now, and it has nothing to do with the dual framework. It is because I have redundant low-version Aspose.Task.dll in the solution, which causes the project calendars to not be displayed in the exported mpp file, even though I have referenced the latest version of the dll.

1 Like