Error when replacing nodes


We are trying to upgrade from aspose.words 13.10 to aspose.words 14.2.1 but are running into a problem. When executing the code in the attachment, an error occurs, which didn’t occur when using aspose words. 13.10.0 (or any other earlier version).

It seems to have something to do with the splitnode we are doing, in combination with the “JoinRunsWithSameFormatting” call we do at the end. It is easy for us to work around this issue by calling the “JoinRunsWithSameFormatting” function after the entire replace, but we are concerned this behavior change also causes error in other places in the system. Can you shed some light on this?


Paul Vrugt
Sr Software Engineer
Infoland BV

Hi Paul,

Thanks for your inquiry. In your case, I suggest you please call the Document.JoinRunsWithSameFormatting method after loading the document and before saving the final document. Do not call this method in IReplacingCallback.Replacing.

Dim _objDocument As New Document(MyDir & "asposeerror.docx")

Dim objRegex As New Regex("@@(\d+?)_[^@]+@@")
_objDocument.Range.Replace(objRegex, New PE_MetaFieldReplacer(), False)
_objDocument.Save(MyDir + "Out.docx")

Moreover, please use the same approach shared at following documentation link to achieve your requirements.

Hope this helps you. Please let us know if you have any more queries.

Hello Tahir,
As I stated in my original post, we know moving the joinrunswithsameformatting function solves the issue. This also wasn’t my question. As I stated, the code in the example used to run fine in aspose.words 13.10.0, but breaks in 14.2.1 . This concerns us, what guarantee we have that is change doesn’t also affect other code? We were hoping you could shed some light on the issue on why this error is now occurring and not in earlier versions, and whether the nature of the change can affect other code.

Hi Paul,

Thanks for your inquiry.

I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-9902. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-9902) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.