We recently went from Aspose.words 13.8 to 14.6. Intermittently we are generating the error “Operation is not valid due to the current stat of the object.”
Stack Trace (not a lot of help, I know)
at ? .()
at ? .(Boolean , Boolean )
at ? . ? ()
at ? .()
at ? .? ()
at ? .(Field )
at ? .(Field )
at ? . (? )
at ? .(? )
at ? .(? , ? )
at ? . ()
at ? .( , Boolean )
at ? . ()
at ? .(? )
at ? .(? , ? )
at ? . ()
at ? .( , Boolean )
at Aspose.Words.Reporting.MailMerge.( )
at KCMS.DAL.MailMerge.MakeASingleFile(Object FileNumberOrReferralId, DataSet& dsMerge, String rootUncKey, FileInfo templateFileInfo, String dateTimeSuffix, String separateDocID, String documentCategory, String includeInCourtTransfer, String eventCode, Int64 EventIndexOrVCompSequenceNumber) in f:\wwroot\CAContraCosta\App_Code\DAL\MailMerge.cs:line 3160
at KCMS.DAL.MailMerge.CreateCaseDocsFromEvent(String TemplateFile, String FileNumber, DateTime EventDate, Int64 DocketSequence, Int64 EventIndex, Boolean IncludeCodefendants, String documentCategory, String witnesses, Int64 ProgramSequenceNumber, String SubpoenaFlag, String includeInCourtTransfer, String eventCode, Boolean SaveIndividualWitnessDocs, String docketCode, DateTime docketDate, String CriminalHistoryIds, String JuryInstructionIDs, String SelectedChargeUIDs, String SelectedCodefendants, List1& uncList) in f:\wwroot\CAContraCosta\App_Code\DAL\MailMerge.cs:line 958</div><div> at Core_EventEntry.GenerateDocuments(TblCtEventCodes& eventCode, TblCsEvents& newCaseEvent, String& nextDocket, String& strSelectedWitnessIDs, String& strSelectedWitnessIDsForDocument, DateTime& nextDocketDate, Int64& intDocketSequenceNumber, Dictionary2& witnessEmailsForDocument, TblCtSystemValues& objSysValues) in f:\wwroot\CAContraCosta\Core\EventEntry.aspx.cs:line 7579
at Core_EventEntry.AddCaseEvent() in f:\wwroot\CAContraCosta\Core\EventEntry.aspx.cs:line 4604
Unfortunately the line number in MakeASingleFile refers to the closing bracket in the method, so I don’t know where the error is generated.
I made an assumption that it was coming from the doc.Save method, so I put in the doc.UpdatePageLayout() workaround mentioned in a post on the same error in Aspose.pdf. No luck, error still occurs.
I have attached the document template “(DRAFT)Complaint.docx” and a text file with method that is calling the merge.