Error when directly programmatically specify all Extended Attributes #269

Hello, there is a problem when exporting to an MPP file. If you save the file without the original template, and directly programmatically specify all ExtendedAttributes, then they either do not appear in the final file, or an error is thrown - Aspose.Tasks.TasksWritingException: Project writing exception.

var project = new Project();

            var table = new Table();
            table.TableFields.Clear();
            
            var w1 = new TableField();
            w1.Field = Field.TaskID;
            table.TableFields.Insert(0, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskWBS;
            w1.Width = 11;
            table.TableFields.Insert(1, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskText21;
            w1.Width = 8;
            table.TableFields.Insert(2, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskName;
            w1.Width = 24;
            table.TableFields.Insert(3, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskText29;
            w1.Width = 20;
            table.TableFields.Insert(4, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskText30;
            w1.Width = 13;
            table.TableFields.Insert(5, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskID;
            w1.Width = 20;
            table.TableFields.Insert(6, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskStart;
            w1.Width = 11;
            table.TableFields.Insert(7, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskFinish;
            w1.Width = 15;
            table.TableFields.Insert(8, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskDuration;
            w1.Width = 11;
            table.TableFields.Insert(9, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskPredecessors;
            w1.Width = 20;
            table.TableFields.Insert(10, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskText28;
            w1.Width = 20;
            table.TableFields.Insert(11, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskText20;
            w1.Width = 24;
            table.TableFields.Insert(12, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskPercentComplete;
            w1.Width = 20;
            table.TableFields.Insert(13, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskStart;
            w1.Width = 20;
            table.TableFields.Insert(14, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskText23;
            w1.Title = "Начало (факт)";
            w1.Width = 15;
            table.TableFields.Insert(15, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskActualStart;
            w1.Title = "Окончание (факт)";
            w1.Width = 17;
            table.TableFields.Insert(16, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskActualFinish;
            w1.Title = "Начало (план)";
            w1.Width = 13;
            table.TableFields.Insert(17, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskBaselineStart;
            w1.Title = "Окончание (факт)";
            w1.Width = 13;
            table.TableFields.Insert(18, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskBaselineFinish;
            w1.Title = "Окончание (факт)";
            w1.Width = 13;
            table.TableFields.Insert(19, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskText22;
            w1.Width = 20;
            table.TableFields.Insert(20, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskText27;
            w1.Width = 11;
            table.TableFields.Insert(21, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskText26;
            w1.Width = 20;
            table.TableFields.Insert(22, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskText24;
            w1.Width = 20;
            table.TableFields.Insert(23, w1);
            
            w1 = new TableField();
            w1.Field = Field.TaskText25;
            w1.Width = 20;
            table.TableFields.Insert(24, w1);
            project.Tables.Add(table);
            
            var newView = new View
            {
                Filter = new Filter
                {
                    Name = "&All Tasks",
                    ShowInMenu = true,
                },
                Group = null,
                HighlightFilter = false,
                Table = table,
                ShowInMenu = true,
                Name = "&Gantt Chart"
            };
            project.Views.Add(newView);

            project.DefaultView = newView;

            SetExtendedAttributes(ref project, listGuidProject, fullInfo.TasksProject);
            var sp = project.ExtendedAttributes;

            if (fullInfo.TasksProject != null)
            {
                var rootTask = project.RootTask;
                foreach (var pointDto in fullInfo.TasksProject)
                {
                    GetTask(rootTask, pointDto, sp);
                }
            
                SetPredecessor(ref project, fullInfo.TasksProject);
            }

            var memoryStream = new MemoryStream();
            
            var saveOptions = new MPPSaveOptions();
            saveOptions.WriteViewData = false;
            
            project.Save(memoryStream, saveOptions);
            
            memoryStream.Position = 0;
            
            return new InfoExportMppDto
            {
                File = memoryStream
            };

@MolokanovTimur,
sadly, but the attached code sample cannot be compiled on our side (For example SetExtendedAttributes method is missing).

However, we were able to reproduce the following case:

A ticket with ID TASKSNET-10721 has been created to resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

We will be grateful if you provide a compilable code example which will allow to reproduce the following case:

The issues you have found earlier (filed as TASKSNET-10721) have been fixed in this update.