Mail merge throws Out of memory using C#

Hello, today we've spend quite some time to find out why our server was running out memory when generating a particular template. Eventually we found out that the following mergefield construction was the problem:

{Mergefield TableStart:Table1}
{ IF { Field1} = "value" {Field2} {Field3} "" }
{Mergefield TableEnd:Table1}

The intended result was that Field2 and Field3 would be shown together.
The fix was easy:

{Mergefield TableStart:Table1}
{ IF { Field1} = "value" "{Field2} {Field3}" "" }
{Mergefield TableEnd:Table1}

Now my question is, is there a way to 'not have the server run out of memory' if the template is not valid? The server is hosting more than this process and the memorypressure is having a bad effect on the overal performance.

Since we are just providing the service to our customers we have little control over (the quality of ) the templates that will be submitted to it. So it is fair to expect invalid templates being submitted on a regular basis.

Greetings Bas Mommenhof.

(Edited to include the TableStart/TableEnd)

Hi Wouter,


Thanks for your inquiry. Could you please attach your input Word document you’re getting problems with here for testing? I will investigate the issue on my side and provide you more information.

Best Regards,

Hi Wouter,

I regret to share with you that Aspose.Words does not support validation of merge fields. However you can work with mail merge by using Aspose.Words. Please read following documentation links for your kind reference.

http://docs.aspose.com/display/wordsnet/Mail+Merge+and+Reporting

Sorry we lost the document where the error was inside.

Please close the issue at this moment. When we can reproduce it we will open it again.

Hi there,


Thanks for your inquiry.

Sure, we will wait for you input. Also note that this issue definitely sounds like a bug and we will gladly look into fixing it as soon as we can reproduce it on our side.

Thanks,