22
Views
9
Comments
Solved
[OfficeUtils] Errors: Collection was modified; enumeration operation may not execute.
officeutils
Service icon
Forge asset by Bruno Gonçalves
Application Type
Service

Hi Bruno, first of all I want to thank you for creating this amazing component.

So I encounter this error message {"Errors":["Collection was modified; enumeration operation may not execute."],"StatusCode":500} when using GenerateWordFile server action

The file is docx file, 59kb, with 65 rows of text replacing, no image and no table

I'm not comfortable sharing the doc and/or the text replacing detail here publicly, if you need it i can send you personally.

Thanks once again and Best Regards,

Alexander Gozali

UserImage.jpg
Bruno Gonçalves
Solution

Hi Alexander,

I was able to reproduce the issue using the template you have provided. It occurs when replacing placeholders with multi-line text, but in very specific circumstances.

I have published a new release of OfficeUtils (5.6.0) that solves the issue.

Best,

Bruno

UserImage.jpg
Bruno Gonçalves

Hi Alexander,

Can you please share the error stack trace? You should be able to find it in service center error logs.

Best,

Bruno

 

UserImage.jpg
Alexander Gozali

Here it is

Collection was modified; enumeration operation may not execute.
   at ssOfficeUtils.RssExtensionOfficeUtilsExternalLib.MssGenerateWordFile(HeContext heContext, IRecord inParamWordFile, Byte[]& outParamWordBinary)
   at ssOfficeUtils.Actions.ActionWord_Export_GenerateFile(HeContext heContext, RCWordFileRecord inParamWordFile, Byte[]& outParamWordBinary)
   at ssConverterOfficeToPDF_API.RsseSpaceOfficeUtils.MssWord_Export_GenerateFile(HeContext heContext, IRecord inParamWordFile, Byte[]& outParamWordBinary)
   at ssConverterOfficeToPDF_API.Actions.ActionWordFileReplacingToBinaryResult(HeContext heContext, STStrReplacingDocumentStructure inParamSource, Byte[]& outParamResult)
   at ssConverterOfficeToPDF_API.CsRESTExpose.Csv1.Csv1ControllerFlows.Flowv1ActionWordBinaryToPDF(HeContext heContext, STStrReplacingDocumentStructure inParamRequest, RCTextBinaryData1Record& outParamFileResult)
   at ssConverterOfficeToPDF_API.CsRESTExpose.Csv1.Csv1Controller.Flowv1ActionWordBinaryToPDF(JSONSTStrReplacingDocumentStructure auxinParamRequest) 

UserImage.jpg
Bruno Gonçalves

Hi Alexander,

This seems to be the stack trace of the error on the OutSystems implementation side. I would expect you to have another log entry (next to this one) with the error stack trace that is internal to the extension.

Bruno

UserImage.jpg
Alexander Gozali

Is it this one?


Collection was modified; enumeration operation may not execute.
   at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
   at OutSystems.NssOfficeUtilsExternalLib.Word.ReplaceTextWithText(XWPFParagraph p, String pattern, Int32 matchIndex, STWordTextStructure wordText)
   at OutSystems.NssOfficeUtilsExternalLib.Word.ProcessParagraph(XWPFParagraph paragraph, RCWordFileRecord ssWordFile, List`1 ParagraphsToRemove)
   at OutSystems.NssOfficeUtilsExternalLib.Word.ProcessParagraphs(IEnumerator paragraphsEnumerator, RCWordFileRecord ssWordFile, List`1 ParagraphsToRemove)
   at OutSystems.NssOfficeUtilsExternalLib.Word.GenerateWordFile(RCWordFileRecord ssWordFile)
   at OutSystems.NssOfficeUtilsExternalLib.CssOfficeUtilsExternalLib.MssGenerateWordFile(RCWordFileRecord ssWordFile, Byte[]& ssWordBinary)
   at ssOfficeUtils.RssExtensionOfficeUtilsExternalLib.MssGenerateWordFile(HeContext heContext, IRecord inParamWordFile, Byte[]& outParamWordBinary) 

UserImage.jpg
Bruno Gonçalves

Yes. This is it.

Are you using any placeholders on your template that have new lines in between? For example:

"#Place\nholder1#"

UserImage.jpg
Alexander Gozali

Not in the placeholder, but there is some \r and \n  in the replacement data.
I've attached the placeholder and replacement json

placeholderandreplacing.txt
UserImage.jpg
Bruno Gonçalves

Hi Alexander,

I might have found the issue. I will be reaching out to you in a private chat to share a new OfficeUtils built for you to test. I can't share it here since the file is too large.


UserImage.jpg
Bruno Gonçalves
Solution

Hi Alexander,

I was able to reproduce the issue using the template you have provided. It occurs when replacing placeholders with multi-line text, but in very specific circumstances.

I have published a new release of OfficeUtils (5.6.0) that solves the issue.

Best,

Bruno

UserImage.jpg
Alexander Gozali

Thanks Bruno

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.