Saving with SaveFileFormat.MPP kills Project document

Hello Aspose team,

in attached project you will find test application which has task to open MPP file (Project1.mpp), find task hyperlinks, make changes and save file under new name (output.mpp).

After I try to open this new file MS Project reports that it cannot be opened.

Am I doing something wrong?

Code is simple:

Private Sub ProcessProject(file As Object)
Try
Dim fi As FileInfo = New FileInfo(file.ToString)
OpenedProjectSize += fi.Length
OpenedProject += 1
Dim locCount As Boolean = False
'Dim fs As FileStream = New FileStream(file.ToString, FileMode.Open, FileAccess.ReadWrite)

        Dim doc As Aspose.Tasks.Project = New Aspose.Tasks.Project(file.ToString)

        Dim collector As Aspose.Tasks.Util.ChildTasksCollector = New Aspose.Tasks.Util.ChildTasksCollector()
        Aspose.Tasks.Util.TaskUtils.Apply(doc.RootTask, collector, 0)

        Dim hpl As String

        For Each tsk As Task In collector.Tasks
            hpl = tsk.Get(Aspose.Tasks.Tsk.Hyperlink)
            If InStr(hpl, "task") <> 0 Then
                hpl = hpl.Replace("task", "ASPOSE")
                tsk.Set(Aspose.Tasks.Tsk.Hyperlink, hpl)
            End If

            tsk.Get(Aspose.Tasks.Tsk.HyperlinkAddress)
            tsk.Get(Aspose.Tasks.Tsk.HyperlinkSubAddress)
        Next

        doc.Save("output.mpp", Aspose.Tasks.Saving.SaveFileFormat.MPP)
        doc = Nothing



    Catch ex As Exception
        Dim exMsg As String = ex.Message
        BadFilesCounter += 1
        BadFiles = BadFilesCounter.ToString + ". " + BadFiles + "File: " + file + ", Error: " + exMsg + vbLf

    End Try
End Sub

Btw. I have Project 2007 on my computer and document is created with it also.

Thanks in advance,
Oliver

Hi Oliver,


Thank you for writing to us again.

Could you please send us the sample project and MPP file, as I cannot see any attachment with this thread?

Hi,



please find attached project with test file.

Test file is in bin/debug folder like output file.



License file is removed from the project.



BR and thanks,

Oliver

Hi Oliver,


Thank you for providing the sample input file. I have tested this issue at my end using the latest version of Aspose.Tasks for .NET 8.0.0 but was unable to observe the problem as you have mentioned. The output MPP file opens fine in Microsoft Project and the task’s hyperlinks are changed as intended. I have attached the output MPP file here for your reference.

Sample Code:


Private Shared Sub TestUSerISsue()

Dim locCount As Boolean = False

Dim doc As New Aspose.Tasks.Project(“Project1.mpp”)


Dim collector As New Aspose.Tasks.Util.ChildTasksCollector()

Aspose.Tasks.Util.TaskUtils.Apply(doc.RootTask, collector, 0)


Dim hpl As String = Nothing


For Each tsk As Task In collector.Tasks

hpl = tsk.Get

'if (string.InStr(hpl, “task”) != 0)

If hpl IsNot Nothing AndAlso hpl.Contains(“task”) Then

hpl = hpl.Replace(“task”, “ASPOSE”)

tsk.[Set](Aspose.Tasks.Tsk.Hyperlink, hpl)

End If


tsk.Get

tsk.Get

Next


doc.Save(“output.mpp”, Aspose.Tasks.Saving.SaveFileFormat.MPP)

End Sub

Hi Kashif,

thanks for test.
File generated on my computer is with same size like yours.

Btw. when I try to open your file (mine also) in MS Project 2007 I am getting same error (see attached screenshot).

Did you try to open your file in Project 2007 or some other version?

Thanks,
Oliver

Hi Oliver,

Thank you for sharing your concern with us.

I was able to reproduce this issue where output MPP file raises exception while opening in MSP 2007 at my end using the latest version of Aspose.Tasks for .NET 8.0.0 and have logged it as TASKS-33877 in our issue tracking system for further investigation by our development team. Once there is any information available in this regard, I'll update you here via this thread.

We are sorry for any inconvenience caused to you.

Hi Kashif,

do you have any estimate when you will work on this issue?

Thanks,
Oliver

Hi Oliver,

The issue is under investigation by our development team and we are planning to fix it in Aspose.Tasks for .NET 7.5.0. We’ll notify you here once there is some information available in this regard.

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


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Kashif,



I have the same problem (or similar) than Oliver.

I use Tasks 8.0.0 for developing.



My intention is creating a project in MPP format from scratch. However, when I save it (obviously in MPP format) it is saved in XML format.



In case I load an existing MPP project and save it (with another name) it is saved also in XML format even I specified MPP format.



Finally, if I open an existing MPP project and save it (same name) with MPP saving options, I am given an access denied exception.



Summarizing, it doesn’t matter the used procedure, I have always the saved project in XML format, not in MPP.



Can you help me, please?



Thanks in advance,



Joan

Hi Joan,


I have tested the scenario using Aspose.Tasks for .NET 7.4.0 and 8.0.0 both by following the steps below:

  1. Open the existing MPP project file
  2. Add a task
  3. Save the project as MPP

It is observed that both the saved MPP project opens successfully in MSP 2010. Could you please test the scenario using latest library Aspose.Tasks for .NET 8.0.0 and let us know the feedback? If your problem is not resolved, please send us the sample project along with the template MPP used for testing.

Following is the sample code:

Project prj = new Project(@“Sample.mpp”);
Task tsk = prj.RootTask.Children.Add(“Task 01”);
prj.Save(@“Modified.mpp”, SaveFileFormat.MPP);


Hi Kashif,

The piece of code that creates the Project file follows:
Dim _fechaInicio As Date
Dim _fechaFin As Date

_fechaInicio = Me.creationDate
_fechaFin = Me.creationDate
If createFechaViaje Then
If fechaViaje < _fechaInicio Then
_fechaInicio = fechaViaje
End If
If fechaViaje > _fechaFin Then
_fechaFin = fechaViaje
End If
End If
If createFechaEntrega Then
If fechaEntrega < _fechaInicio Then
_fechaInicio = fechaEntrega
End If
If fechaEntrega > _fechaFin Then
_fechaFin = fechaEntrega
End If
End If
If createFechaApertura Then
If fechaApertura < _fechaInicio Then
_fechaInicio = fechaApertura
End If
If fechaApertura > _fechaFin Then
_fechaFin = fechaApertura
End If
End If

Dim _project As New Project() ’ New Project is created

_project.Set(Prj.Company, My.Application.Info.CompanyName)
_project.Set(Prj.Author, username)
_project.Set(Prj.ScheduleFromStart, True)
_project.Set(Prj.Title, Me.code & " - " & Me.name)
_project.Set(Prj.Name, _project.Get(Prj.Title))
_project.Set(Prj.Subject, Me.cliente)
_project.Set(Prj.StartDate, _fechaInicio)
_project.Set(Prj.FinishDate, _fechaFin)
_project.Set(Prj.MinutesPerDay, 480)
_project.Set(Prj.MinutesPerWeek, 2400)
_project.Set(Prj.CurrencyDigits, 2)
_project.Set(Prj.CurrencySymbol, “€”)
_project.Set(Prj.CurrencyCode, “EUR”)
_project.Set(Prj.CurrencySymbolPosition, CurrencySymbolPositionType.AfterWithSpace)
_project.Set(Prj.DefaultStartTime, “09:00:00”)
_project.Set(Prj.DefaultFinishTime, “19:00:00”)
_project.Set(Prj.DaysPerMonth, 20)
_project.Set(Prj.DurationFormat, TimeUnitType.ElapsedWeek)
_project.Set(Prj.WorkFormat, TimeUnitType.Hour)
_project.Set(Prj.ActualsInSync, True)

Dim _rootTask As Task = _project.RootTask
If createFechaViaje Then
Me.createTask(_rootTask, “Salida viaje entrega de plicas”, fechaViaje)
End If
If createFechaEntrega Then
Me.createTask(_rootTask, “Entrega de plicas”, fechaEntrega)
End If
If createFechaApertura Then
Me.createTask(_rootTask, “Apertura de plicas”, fechaApertura)
End If

'_project.CalcTaskIds()
'_project.CalcTaskUids()
_project.CalcResourceFields()
'_project.CalcResourceIds()
'_project.CalcResourceUids()
_project.Recalculate()

Dim _planningFile As String = Me.getPlanningFileName
_project.Save(_planningFile, TasksDataFormat.MPP)

The result is a file named “Planning.mpp”. If you open this file using the notepad, it looks as follows:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
14
ASPOSE3 - ASPOSE3
ASPOSE3 - ASPOSE3
MMESP\JoanOliver
2010-09-21T10:06:00
2015-02-18T12:10:08
1
2015-02-18T12:10:06
2015-02-25T12:09:50
1
0
2
EUR
3
1
09:00:00
19:00:00
480
2400
20
0
3
0
0
10
2
0
0
1
0
1
1
1
0
0
1
0
1
0
0
0
0
0
1
2015-02-18T08:00:00
0
1
0
0
0
0
1984-01-01T00:00:00
1
0
0
1
0
1
Estándar
1
0
-1
1
0
2
1
09:00:00
13:00:00
15:00:00
19:00:00
3
1
09:00:00
13:00:00
15:00:00
19:00:00
4
1
09:00:00
13:00:00
15:00:00
19:00:00
5
1
09:00:00
13:00:00
15:00:00
19:00:00
6
1
09:00:00
13:00:00
15:00:00
19:00:00
7
0
0
0
1
0
1
0
2010-09-21T12:06:00
0
0
0
500
2015-02-19T12:09:50
2015-02-25T12:09:50
PT32H0M0S
2015-02-19T12:09:50
2015-02-25T12:09:50
PT32H0M0S
21
PT0H0M0S
0
0
0
0
1
0
1
0
1
0
0
0
2015-02-19T12:09:50
2015-02-25T12:09:50
2015-02-25T12:09:50
2015-02-25T12:09:50
0
0
0
0
0
0
0
0
3
0
0
0
0
PT0H0M0S
PT0H0M0S
0
0
PT0H0M0S
PT0H0M0S
PT0H0M0S
PT32H0M0S
0
PT0H0M0S
0
PT0H0M0S
0
0
0
-1
1
1
0
8
0
0
0
0
0
0
0
1
0
0
PT0H0M0S
PT0H0M0S
21
1
1
Salida viaje entrega de plicas
1
0
0
2015-02-18T12:10:07
3
1
500
2015-02-19T12:09:50
2015-02-19T12:09:50
PT0H0M0S
2015-02-19T12:09:50
2015-02-19T12:09:50
PT0H0M0S
7
PT0H0M0S
0
1
0
0
1
1
0
0
0
0
0
0
2015-02-19T12:09:50
2015-02-19T12:09:50
2015-02-25T12:09:50
2015-02-25T12:09:50
0
0
0
19200
19200
19200
19200
0
3
0
0
0
0
PT0H0M0S
2015-02-19T12:09:50
PT0H0M0S
0
0
PT0H0M0S
PT0H0M0S
PT0H0M0S
PT0H0M0S
0
PT0H0M0S
0
PT0H0M0S
0
0
6
-1
2015-02-19T12:09:50
1
1
0
8
0
0
0
0
0
0
0
1
0
2
2
Entrega de plicas
1
0
0
2015-02-18T12:10:08
3
1
500
2015-02-21T12:09:50
2015-02-21T12:09:50
PT0H0M0S
2015-02-21T12:09:50
2015-02-21T12:09:50
PT0H0M0S
7
PT0H0M0S
0
1
0
0
1
1
0
0
0
0
0
0
2015-02-21T12:09:50
2015-02-21T12:09:50
2015-02-25T12:09:50
2015-02-25T12:09:50
0
0
0
11490
11490
11490
11490
0
3
0
0
0
0
PT0H0M0S
2015-02-21T12:09:50
PT0H0M0S
0
0
PT0H0M0S
PT0H0M0S
PT0H0M0S
PT0H0M0S
0
PT0H0M0S
0
PT0H0M0S
0
0
6
-1
2015-02-21T12:09:50
1
1
0
8
0
0
0
0
0
0
0
1
0
3
3
Apertura de plicas
1
0
0
2015-02-18T12:10:08
3
1
500
2015-02-25T12:09:50
2015-02-25T12:09:50
PT0H0M0S
2015-02-25T12:09:50
2015-02-25T12:09:50
PT0H0M0S
7
PT0H0M0S
0
1
0
0
1
1
0
0
1
0
0
0
2015-02-25T12:09:50
2015-02-25T12:09:50
2015-02-25T12:09:50
2015-02-25T12:09:50
0
0
0
0
0
0
0
0
3
0
0
0
0
PT0H0M0S
2015-02-25T12:09:50
PT0H0M0S
0
0
PT0H0M0S
PT0H0M0S
PT0H0M0S
PT0H0M0S
0
PT0H0M0S
0
PT0H0M0S
0
0
6
-1
2015-02-25T12:09:50
1
1
0
8
0
0
0
0
0
0
0
1
0
0
0
1
0
0
1
0
0
1
3
PT0H0M0S
PT0H0M0S
PT0H0M0S
PT0H0M0S
PT0H0M0S
PT0H0M0S
PT0H0M0S
0
0
2
0
0
2
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
2015-02-18T12:10:07
0
0

If can be correctly imported in MSProject, but it is definitively not a MSProject file.

Best Regards,

Joan

Hi Joan,


Thank you for sharing your concern with us.

Project.Save function requires two arguments as follows:

  1. String file name
  2. SaveFileFormat enumerator

If you have a look on SaveFileFormat enumerator, it contains following members:
XML = 1, MPP = 0

However you are using TasksDataFormat which contains following members:
XML = 0, MPP = 1

As Project.Save is expecting SaveFileFormat as second argument, so when you save the project, you set TaskDataFormat.MPP which is 1, BUT in SaveFileFormat 1 means XML, that is why the .mpp file contains XML contents.

Could you please use SaveFileFormat enumerator and let us know the feedback?

Oh, God!!!!

Thanks a lot, Kashif.

Everything is going right, now!!!

Hi Joan,


We are glad to know that your issue is resolved and thank you for providing feedback. Please feel free to write us back if you have any other query related to Aspose.Tasks.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.