Blank Word doc after mail merge

We are seeing an issue on production where intermittently all mail merge docs are blank. We have a windows service that processes and creates the mail merge doc, intermittently blank docs are getting generated. Once this starts happening all subsequent mail merge docs are blank until we restart the service. Once the service is restarted it works fine for a few days and we have the same issue again.It is not possible to generate a reproduction for this, so we are trying to see what could be creating blank docs and why would restarting it fix the issue. Looking for any pointers that can help track down the issue.
Also, it is not related to a specific doc since all docs are blank (regardless of the merge fields/template)

@pparikh

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please share code of service (without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.
  • Please share your working environment.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Hi @tahir.manzoor
I don’t have a way to reproduce this since this is happening intermittently only in production. Restarting the service fixed the issue. Looking for any pointers you can help with without a reproduction case.

Similar case - Periodic failures generating blank documents
Can you outline in what cases does Aspose produce a blank word doc? We are initializing the Document object every time a mail merge has to be done so I would think that the new document should not be impacted by incorrect tablestart/end or any other incorrect structure within a previous document. Once the document is created, we clone it and then call the Merge methods. Is that Merge method somehow not thread safe and one document is impacting the other document?

@pparikh

Your issue is not related to TableStart and TableEnd fields. If one of the field is missed from document, you will get the exception.

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.

If you still face problem, please ZIP and attach the requested resources here for testing. We will investigate the issue and provide you more information on it. Thanks for your cooperation.

@tahir.manzoor
Since this is running on a windows service, there is definitely a case where one thread processes multiple documents sequentially. Thread picks up the document to process, creates a new instance of the Document, does a mail merge and then it picks up the next document in queue, creates a new instance of the document and continues processing everything in queue. Is there something we can add to flush out, clear out before the next document is picked up for processing? Any help is appreciated.

@pparikh

Please note that one thread should use one Document object. In your case, I suggest you please use the lock the process (mail merge and other document processing tasks). We suggest you please read the following article. Hope this helps you.
Managed threading best practices