Free Support Forum - aspose.com

HTML to PDF Conversion issue throws System.InvalidOperationException using .NET

Unable to generate PDFs due to below issue, getting lots of escalations from customers. Please try to solve this problem asap as we have purchased Aspose.Total license.

2021-02-23T12:02:16.8848534+05:30 [ERR] Error Code: EIC-LI-UL | Error Message: Exception While Generating PDF from Method - GenerateInvoicePdfETL | Exception: System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection’s state is no longer correct.
at System.Collections.Generic.Dictionary2.FindEntry(TKey key) at System.Collections.Generic.Dictionary2.TryGetValue(TKey key, TValue& value)
at   .(Char )
at   .(Int32 )
at    . (   , Boolean )
at    .(String ,     , Boolean )
at Aspose.Words.Fields.FieldHyperlink.()
at    . ()
at    .     ( ​  )
at    .     ( ​  )
at    . ( ​  ,     )
at    .     ( ​  )
at    .     ( ​  )
at    .     ( ​  )
at  ​ . (    )
at  ​ . (    ,     )
at    .(    ,  ​  )
at    .     (    )
at    .     (    )
at Aspose.Words.Document.  (    )
at Aspose.Words.Document.​(Stream , String , SaveOptions )
at Bolton.EinvoiceEwayBill.Domain.FileManager.SaveInvoiceFile(Document document, Int32 OrganizationID, String year, String month, Boolean Force, String FileName, String SubModule, Boolean saveRecord) in /home/vsts/work/1/s/Bolton.EinvoiceEwayBill.Domain/FileManager.cs:line 646
at Bolton.EinvoiceEwayBill.Domain.GenerateEInvoiceDocumentServiceManager.GenerateInvoicePdfETL(Int32 organizationId, String outFileName, OutwardDocumentHeaderViewModel OutwardDocumentHeaderDetails, List1 lineItemDetails, List1 ewaybillDocumentDetails, EinvoiceIrnDetails einvoiceIrnDetails, EnumerableRowCollection`1 templateInfo, Int32 outwardDocumentHeaderID, Int32 irnId) in /home/vsts/work/1/s/Bolton.EinvoiceEwayBill.Domain/GenerateEInvoiceDocumentServiceManager.cs:line 326 (018efa8c)

@VenkateshBT

Aspose.Words does support multi-threading. The only thing you need to make sure is that always use separate Document instance per each thread. One thread should use one Document object (one single template).

If you still face problem, please ZIP and attach your input documents along with sample code example to reproduce this issue at our end. We will investigate the issue and provide you more information on it.