Mail Merge Template with Related Record in the Header and a Table of Contents will fail

Mail Merge Template with Related Record in the Header and a Table of Contents will fail. Removing the Table of Contents OR the Related Record from Header will not cause error. Attached is the template file.

I am using Aspose.Words for .Net 14.2.0.0 version


1. Create Mail Merge Template for Divisions module and upload the attached .docx file.

2. Create a Division record, create a Business Unit record, and link the two records.
3. From Division record, export to the Mail Merge Template...notice the error.
4. This will generate below exception.
5. Remove the Table of Contents OR the Related Record field from Header...notice the Mail Merge Template works


Important parts from exception:

Object reference not set to an instance of an object.
Aspose.Words
at xfbd1009a0cbb9842.xfedf115fd9c03862.x93a5aef725ab1a13(x5e36356bc92c609b x0f7b23d1c393aed9)
at xfbd1009a0cbb9842.xfedf115fd9c03862.x1d125084aa46bebd(x5e36356bc92c609b x0f7b23d1c393aed9)
at xfbd1009a0cbb9842.xfedf115fd9c03862.x0f4b7f3b2ee62d4b(x5e36356bc92c609b x0f7b23d1c393aed9)
at xfbd1009a0cbb9842.xfedf115fd9c03862.x945dc04ac4e4f5ab(xb0b76bad05a97c8b xd3311d815ca25f02)
at xfbd1009a0cbb9842.xfedf115fd9c03862.x7b62f4210c900502(xcf417e2db4fe9ed3 xb1a1ccf3b9674a87, xcf417e2db4fe9ed3 x8f8ce337d74845ae)
at xfbd1009a0cbb9842.xfedf115fd9c03862.x85b3fe0bc4c02f7f(Field xe01ae93d9fe5a880, xdac068096ca09318 xb4edacb3d605f604)
at xfbd1009a0cbb9842.xfedf115fd9c03862.x92ce4c0c56b83b47(Field xe01ae93d9fe5a880, xdac068096ca09318 xb4edacb3d605f604)
at x4adf554d20d941a6.x5c28fdcd27dee7d9.x295cb4a1df7a5add(Field xe01ae93d9fe5a880, x9b9129deff8239b5 x0f7b23d1c393aed9, Boolean xe8a11c0a188a49d7)
at x4adf554d20d941a6.x4e2f8bff72d83f71.x836cc4d43484aecd(xac6c82c74ce247fb x2612f62f94df47de)
at x4adf554d20d941a6.x4e2f8bff72d83f71.x17e48e42e094d16c(xa268fdb9ca040dde xd07ce4b74c5774a7)
at x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98(Document x3664041d21d73fdc, LayoutOptionsCore xdfde339da46db651)
at Aspose.Words.Document.UpdatePageLayout()
at xfbd1009a0cbb9842.xea4db0348fef2cb4.xb333e1e6c01c2be2(xcf417e2db4fe9ed3 xe00c282e1a49fcfb)
at xfbd1009a0cbb9842.xfedf115fd9c03862.x7b62f4210c900502(xcf417e2db4fe9ed3 xb1a1ccf3b9674a87, xcf417e2db4fe9ed3 x8f8ce337d74845ae)
at xfbd1009a0cbb9842.xfedf115fd9c03862.x118a2acc122f2bb3()
at xe86f37adaccef1c3.xc5c3f438428cb03b.xdeeb682062ef79a5()
at xe86f37adaccef1c3.xc5c3f438428cb03b.xd5da23b762ce52a2(xa11a4c48b53f49a6 xef1769c4fe6ae4ca, Boolean xc9c7b90943167aed)
at Aspose.Words.Reporting.MailMerge.x18dfca7c5fd2402f(xa11a4c48b53f49a6 xef1769c4fe6ae4ca)
at ArcherTech.MailMerge.MailMergeDocument.Merge(EntityList reader)
at ArcherTech.MailMerge.MailMergeService.PerformMailMerge(MailMergeProperties properties)
at ArcherTech.Kernel.Brokers.PrintExportBroker.PerformMailMerge(Int32 contentId, Int32 mailMergeTemplateId, Int32 exportInfoId, User user, Boolean isAsync)


Hi Rohit,

Thanks for your inquiry. The TableEnd region is missing in the header of your document. Please add this field. We have tested the scenario using latest version of Aspose.Words for .NET 16.4.0 and have not found the shared exception. Please use Aspose.Words for .NET 16.4.0 and let us know if you have any more queries.