I have noticed that when issuing FileSave and then FileSaveAs immediately after causes MS Project to hang without any error. The offending code is:
Public Sub CleanXML(file As String)
Dim oActiveApp As MSProject.Application = GetObject(, "MSProject.Application")
oActiveApp.FileSave()
oActiveApp.FileSaveAs(Name:=file, FormatID:="MSProject.XML")
Try
Dim xmlDoc As XElement = XElement.Load(file)
Dim junk =
From jk In xmlDoc.Elements
Where jk.Name.LocalName = "Tasks"
Select jk
Dim children =
From ch In junk.Elements
Where ch.Descendants.ElementAt(3).Name.LocalName <> "Name"
Select ch
children.Remove
xmlDoc.Save(file)
Catch ex As System.Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
But in reality, it never finishes executing FileSaveAs. I have noticed that if calling FileSaveAs first and then FileSave doesn't cause the same problem.
The open Project file is on the remote server (connection speed avg is 400Kbps) and the XML is saving on the machine locally. If the Project file is also local this doesn't happen.
Any idea what could be causing this issue?