Document causes .SAVE to hang

One of our clients complained about our software “hanging”. I have since been able to avoid the issue by wrapping the code in a Task so I can abort it if it takes more than 10 seconds, but of course the main issue is that the .SAVE method fails to complete.

The code is (with all error handling and niceties like that stripped out, VB.NET code. sFile is the original file path, sToFileName = the target file path somepath\somefile.pdf for example)

Dim oDoc As Aspose.Words.Document = Nothing
oDoc = New Aspose.Words.Document(sFile)
With oDoc.LayoutOptions.RevisionOptions
    .ShowRevisionBars = False
    .ShowRevisionMarks = False
End With
oDoc.Save(fileName:=sToFileName, saveFormat:=Aspose.Words.SaveFormat.Pdf)

The attached file has this problem. We’re using Aspose.Words for .NET version 22.2.0, our project is a VB.NET project targeting .NET Framework 4.8

test.docx (55.7 KB)

@kidkeogh I was managed to reproduce your issue on my side. I have logged it as WORDSNET-23529 in our defect tracking system. We will keep you informed and let you know once it is resolved.

1 Like

Hello @Konstantin.Kornilov

Ok, I’m looking forward to the resolution BUT … the current problem leaves us in a fix.

The code gets stuck on the .Save statement. It never moves on from there. But as it does this it keeps ramping up the memory usage.

When I perform this process in a System.Threading.Tasks.Task I can specify a wait time and consider the process “hung” at that point. But it continues on even after the wait time expires and it never stops. And the memory goes up and up and up and our application grinds to a halt.

So I need to do something about that. Is there a way I can force the .Save to abort? I can’t see a way to Dispose the Aspose.Words.Document object?

At the moment our only option is to raise an event when we detect this “hang”, and the main application can monitor this event and close itself down, forcing all processes, including the “hanging” one, to end. Not ideal, but better than allowing our application to slow down and become unusable over time, without the user realising what is really going on.

@kidkeogh In your case the process hangs on the layout stage. You could use IPageLayoutCallback to cancel the layout process at some point. Also there is high probability that your issue will be fixed in the next Aspose.Words for .NET 22.3 release (though there is no guarantee).

1 Like

Thanks Konstantin, that worked a treat.

@Konstantin.Kornilov also - we updated our nuGet package for Aspose.Words to 22.3 and I can confirm that the issue is now fixed at source. Happy days :slightly_smiling_face:

The issues you have found earlier (filed as WORDSNET-23529) have been fixed in this Aspose.Words for .NET 22.4 update also available on NuGet.