Error: Object reference not set to an instance of an object while UpdateFields() in template

Hi,

We are facing problem with one of our clients while UpdateFields() in template. Here is the Reproduction of issue. Please take a look and get back to us with a resolution.

Regards,

@kkurra The problem is caused by RemoveEmptyRegions visitor, which damages the document structure. It looks like your goal is to remove unmerged regions in your document. You can easily do this using MailMergeCleanupOptions.RemoveUnusedRegions. Just use the following simple code instead the visitor:

finalTemplate.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveUnusedRegions
finalTemplate.MailMerge.ExecuteWithRegions(New DataTable())