Project attributes missing when application in hosted in IIS (C# .NET)

when use aspose.task to export task data from mysql database to ms project file, it becomes very slowly if data items count more than 2000. How to optimize performance and shorten export time?

@Ervin_Zhang,

Can you please share source file so that we may further investigate to help you out.

Dear Adnan.Ahmad,
Thank you for reply. Now I Change the Calculation Mode to manual, and this method is very effective. If I encounter other problem, contact you again.
Wish you have a nice day.

@Ervin_Zhang,

Thank you for sharing the valuable feedback.

I have created a Asp.net MVC project by using Visual Studio 2017, and used aspose.tasks for .NET (18.11) to import/export MPP. When I run the project to export Msproject file in my localhost, there is no problem. But when I deploy my project on windows server 2012, IIS 8.5, it throws an error,“System.OutMemoryExcption”.
Error Log:
Time:2019-05-14 14:45:54,292
ThreadID:[243]
LogLevel:ERROR
Location:QDP.Code.Log.Error(E:\workspace\SVN\trunk\QDP.Code\Log\Log.cs:36)
MessageDes:(null)
Exception:
Message:exprot mpp Error! Aspose.Tasks.TasksWritingException: Project writing exception. —> System.OutOfMemoryException: Raises an exception of type “System. OutOfMemoryException”。
In ???.()
In ???.???(IDictionary`2 )
In ???.???()
— End of internal exception stack trace —
In ???.???()
In ???.(??? )
In ???.?()
In ???.()
In ???.???(Project , Stream )
In ???.(Stream , MPPSaveOptions )
In ???.(Stream , SaveFileFormat )
In Aspose.Tasks.Project.Save(String filename, SaveFileFormat format)
In QDP.Web.Areas.ProjectManagement.Controllers.ProjectController.ExportMpp(String projectId, String role, String ResponsibleTeam) location E:\workspace\SVN\trunk\QDP.Web\Areas\ProjectManagement\Controllers\ProjectController.cs: Line Num 3972 (code: var projectnameExtendedAttributeText6=ProjectNameExtendedAttribute.CreateExtendeAtrribute():wink:

What’s the reason for this problem?

@Ervin_Zhang,

Can you please try to use Aspose.Task latest version 19.4 on your end and share feedback with us if there is still an issue.

I have changed the dll from version 18.11.0 to 19.4.0, but it still not run correctly.
Error Log,
Time:2019-05-15 14:50:38,071
ThreadID:[95]
LogLevel:ERROR
MessageDes:(null)
Exception:
Message:add task to mpp Exception: System.InvalidOperationException: This property cannot be used for an ExtendedAttribute with ‘Number’ type.
在 Aspose.Tasks.ExtendedAttribute.#=zjxEkXzRnOK9P(CustomFieldType[] #=zzrsJuLRQjDpO)
在 Aspose.Tasks.ExtendedAttribute.set_TextValue(String value)
在 QDP.Web.Areas.ProjectManagement.Controllers.ProjectController.CreateMppTask(Task qdpTask, Task root, Project project, ProjectEntity projectEntity)
在 QDP.Web.Areas.ProjectManagement.Controllers.ProjectController.AddMppTask(List`1 qdpTaskList, Task qdpTask, Task root, Project project, String ResponsibleTeam, String role, ProjectEntity projectEntity)

Resource Code,
var workproduct = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Text, ExtendedAttributeTask.Text1, “WorkProduct”);
project.ExtendedAttributes.Add(workproduct);
var taskExtendedAttributeText1 = workproduct.CreateExtendedAttribute();
taskExtendedAttributeText1.TextValue = projectask.WorkProduct;
root.ExtendedAttributes.Add(taskExtendedAttributeText1);

                    //Create an Extended Attribute Definition of Text3 type(CRUD Flag)
                    var TaskIDExtendedAttribute = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Text, ExtendedAttributeTask.Text9, "TaskID");
                    project.ExtendedAttributes.Add(TaskIDExtendedAttribute);
                    var taskExtendedAttributeText9 = TaskIDExtendedAttribute.CreateExtendedAttribute();
                    taskExtendedAttributeText9.TextValue = projectask.IssueId;
                    root.ExtendedAttributes.Add(taskExtendedAttributeText9);

                    //Create an Extended Attribute Definition of Text4 type(BPM Item ResponsibleTeam)
                    var ResponsibleTeamExtendedAttribute = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Text, ExtendedAttributeTask.Text15, "ResponsibleTeam");
                    project.ExtendedAttributes.Add(ResponsibleTeamExtendedAttribute);
                    var taskExtendedAttributeText15 = ResponsibleTeamExtendedAttribute.CreateExtendedAttribute();
                    taskExtendedAttributeText15.TextValue = projectask.ResponsibleTeam;
                    root.ExtendedAttributes.Add(taskExtendedAttributeText15);

                    //Create an Extended Attribute Definition of Text5 type(BPM Item parent issueId)
                    var ParentIdExtendedAttribute = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Text, ExtendedAttributeTask.Text5, "ParentID");
                    project.ExtendedAttributes.Add(ParentIdExtendedAttribute);
                    var taskExtendedAttributeText5 = ParentIdExtendedAttribute.CreateExtendedAttribute();
                    taskExtendedAttributeText5.TextValue = "";
                    root.ExtendedAttributes.Add(taskExtendedAttributeText5);

                    //Create an Extended Attribute Definition of Date1 type(Due Date)
                    var DueDate = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Date, ExtendedAttributeTask.Date1, "Due Date");
                    project.ExtendedAttributes.Add(DueDate);
                    var taskExtendedAttributeDate1 = DueDate.CreateExtendedAttribute();
                    if (!String.IsNullOrEmpty(projectask.DueDate))
                    {
                        taskExtendedAttributeDate1.DateValue = Convert.ToDateTime(projectask.DueDate);
                    }
                    root.ExtendedAttributes.Add(taskExtendedAttributeDate1);

                    //Create an Extended Attribute Definition of Text4 type(BPM Item TaskType)
                    var TaskTypeExtendedAttribute = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Text, ExtendedAttributeTask.Text4, "TaskType");
                    project.ExtendedAttributes.Add(TaskTypeExtendedAttribute);
                    var taskExtendedAttributeText4 = TaskTypeExtendedAttribute.CreateExtendedAttribute();
                    taskExtendedAttributeText4.TextValue = projectask.IssueType;
                    root.ExtendedAttributes.Add(taskExtendedAttributeText4);

                    //Create an Extended Attribute Definition of Text4 type(BPM Item State)
                    var TaskStateExtendedAttribute = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Text, ExtendedAttributeTask.Text3, "State");
                    project.ExtendedAttributes.Add(TaskStateExtendedAttribute);
                    var taskExtendedAttributeText3 = TaskStateExtendedAttribute.CreateExtendedAttribute();
                    taskExtendedAttributeText3.TextValue = projectask.State;
                    root.ExtendedAttributes.Add(taskExtendedAttributeText3);

                    //Create an Extended Attribute Definition of Text4 type(BPM Item TaskType)
                    var PercentDoneExtendedAttribute = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Number, ExtendedAttributeTask.Number1, "Percentagedone");
                    project.ExtendedAttributes.Add(PercentDoneExtendedAttribute);
                    var taskExtendedAttributeNum1 = PercentDoneExtendedAttribute.CreateExtendedAttribute();
                    taskExtendedAttributeNum1.NumericValue = Convert.ToInt16(projectask.Progress * 100);
                    root.ExtendedAttributes.Add(taskExtendedAttributeNum1);

                    //Create an Extended Attribute Definition of Text6 type(BPM Item ProjectName)
                    var ProjectNameExtendedAttribute = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Text, ExtendedAttributeTask.Text6, "ProjectName");
                    project.ExtendedAttributes.Add(ProjectNameExtendedAttribute);
                    var projectNameExtendedAttributeText6 = ProjectNameExtendedAttribute.CreateExtendedAttribute();
                    projectNameExtendedAttributeText6.TextValue = projectItem.F_ProjectName;
                    root.ExtendedAttributes.Add(projectNameExtendedAttributeText6);

All right in Localhost , but in server also has problem as below show.

@Ervin_Zhang,

I have observed OutOfMemory exception related issue shared by you. Can you please try to convert your MVC application to x64 from project settings and also deploy and x64 based application in IIS and then try. It doesn’t seem to be an API issue as if it were an API issue then it would have been reproduced in normal application too.

Hello!

BTW, the exception is different on 19.4. Please change the line:

var PercentDoneExtendedAttribute = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Number, ExtendedAttributeTask.Number1, "Percentagedone");

to

var PercentDoneExtendedAttribute = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Number, ExtendedAttributeTask.Number1, 100); // set correct numeric value here.

to get correct code sample.

There is no overloading of the method ‘CreateTaskDefinition’, to using an int parameter .

Yes, you are right. You need to change the line

projectNameExtendedAttributeText6.TextValue = projectItem.F_ProjectName;

to

projectNameExtendedAttributeText6.NumericValue = 100; // correct numeric value

instead of the line I mentioned in my previous post.

It seems like that the order of project extend attributes is chaotic.
Export mpp file by different way, as below,
server.PNG (5.6 KB)
localhost.PNG (8.1 KB)

add attribute to task code,

        / /Create an Extended Attribute Definition of Text1 type(work Product)
        var taskExtendedAttributeText1 = project.ExtendedAttributes[0].CreateExtendedAttribute();
        taskExtendedAttributeText1.TextValue = qdpTask.WorkProduct;
        task1.ExtendedAttributes.Add(taskExtendedAttributeText1);

        //Create an Extended Attribute Definition of Text2 type(CRUD identifier)

        var taskExtendedAttributeText2 = project.ExtendedAttributes[1].CreateExtendedAttribute();
        taskExtendedAttributeText2.TextValue = qdpTask.Identifier;
        task1.ExtendedAttributes.Add(taskExtendedAttributeText2);

        //Create an Extended Attribute Definition of Text3 type(IssueType)
        var taskExtendedAttributeText3 = project.ExtendedAttributes[3].CreateExtendedAttribute();
        taskExtendedAttributeText3.TextValue = qdpTask.IssueType;
        task1.ExtendedAttributes.Add(taskExtendedAttributeText3);

        //Create an Extended Attribute Definition of Text4 type(IssueId)
        var taskExtendedAttributeText4 = project.ExtendedAttributes[6].CreateExtendedAttribute();
        taskExtendedAttributeText4.TextValue = qdpTask.IssueId;
        task1.ExtendedAttributes.Add(taskExtendedAttributeText4);
        if (qdpTask.IssueType != "Release")
        {
            var parentTask = tasksApp.GetForm(qdpTask.ParentId);
            while (string.IsNullOrEmpty(parentTask.IssueId)&&parentTask.ParentId!="0")
            {
                string id = parentTask.ParentId;
                parentTask = tasksApp.GetForm(id);
            }
            qdpTask.ParentId = parentTask.IssueId;
            //Create an Extended Attribute Definition of Text5 type(IssueId)
            var taskExtendedAttributeText5 = project.ExtendedAttributes[4].CreateExtendedAttribute();
            taskExtendedAttributeText5.TextValue = qdpTask.ParentId;
            task1.ExtendedAttributes.Add(taskExtendedAttributeText5);
        }

@Ervin_Zhang,

I have observed the comparison images. An issue with ID TASKSNET-3211 has been added in our issue tracking system to further investigate the issue. This thread has been linked with issue so that you may be notified once issue will be addressed.

@Ervin_Zhang,

Can you please try toset the ExtendedAttributes’ values to fixed literals on the IIS using the following code and share screenshots with us.

        / /Create an Extended Attribute Definition of Text1 type(work Product)
        var taskExtendedAttributeText1 = project.ExtendedAttributes[0].CreateExtendedAttribute();
        taskExtendedAttributeText1.TextValue = "Work Product test value";
        task1.ExtendedAttributes.Add(taskExtendedAttributeText1);

        //Create an Extended Attribute Definition of Text2 type(CRUD identifier)

        var taskExtendedAttributeText2 = project.ExtendedAttributes[1].CreateExtendedAttribute();
        taskExtendedAttributeText2.TextValue = "Identifier test value";
        task1.ExtendedAttributes.Add(taskExtendedAttributeText2);

        //Create an Extended Attribute Definition of Text3 type(IssueType)
        var taskExtendedAttributeText3 = project.ExtendedAttributes[3].CreateExtendedAttribute();
        taskExtendedAttributeText3.TextValue = "Issue type test value";
        task1.ExtendedAttributes.Add(taskExtendedAttributeText3);

        //Create an Extended Attribute Definition of Text4 type(IssueId)
        var taskExtendedAttributeText4 = project.ExtendedAttributes[6].CreateExtendedAttribute();
        taskExtendedAttributeText4.TextValue = "IssueId test value";
        task1.ExtendedAttributes.Add(taskExtendedAttributeText4);
        if (qdpTask.IssueType != "Release")
        {
            var parentTask = tasksApp.GetForm(qdpTask.ParentId);
            while (string.IsNullOrEmpty(parentTask.IssueId)&&parentTask.ParentId!="0")
            {
                string id = parentTask.ParentId;
                parentTask = tasksApp.GetForm(id);
            }
            qdpTask.ParentId = parentTask.IssueId;
            //Create an Extended Attribute Definition of Text5 type(IssueId)
            var taskExtendedAttributeText5 = project.ExtendedAttributes[4].CreateExtendedAttribute();
            taskExtendedAttributeText5.TextValue = "IssueId test value";
            task1.ExtendedAttributes.Add(taskExtendedAttributeText5);
        }

@Ervin_Zhang Hello!
Can you please notify - is the issue resolved by the solution proposed by us?