Encounter Null Reference Exception During Word Mail Merge by Using Latest Version of Aspose.Words

HI,

In order to use provided new hyphenation functionality in Aspose.Words in our system, we tried using latest version of Aspose.Words, but before converting word to pdf, we encountered NULL Reference exception when executing mail merge in our report. I attached sample code here:

static void Main(string[] args) {

//TestMergeField("2014_DEDirectPromise.docx");

//TestMergeField("2014_DEJubilee.docx");

TestMergeField("2014_DESupportFund.docx");

}

static void TestMergeField(string templateFileName){

//try

//{

License lic = new License();

lic.SetLicense("Aspose.Total.lic");

            </p><p>Document doc = new Document(templateFileName);

            </p><p>var dic = GetDataDictionary();
            </p><p>var keys = dic.Keys.ToArray();
            </p><p>var values = dic.Values.ToArray();

doc.MailMerge.Execute(keys, values);

            </p><p>doc.Save(string.Format("{0}.docx", DateTime.Now.ToString("yyyyMMddHHmmss")));

Console.WriteLine("Process Merge Field successfully!");

Console.ReadLine();

//}

//catch (Exception ex)

//{

// Console.WriteLine(ex.Message);

//} }

    </p><p>static Dictionary<string,object> GetDataDictionary()
    </p><p>{

Dictionary dic = new Dictionary();

//dic["AUSGAT"] = DateTime.MinValue;

dic["ClientCode"] = "ABS";

//dic["$PENS"] = true;

//dic["BITAG"] = DateTime.Now;

//dic["FNAME"] = "FNAME";

//dic["FORT"] = "FORT";

//dic["$TRADE"] = true;

//dic["NUMBERLT"] = 0;

//dic["$TAX"] = false;

//dic["$IFRS"] = true;

//dic["$US"] = false;

//dic["$PSV"] = true;

//dic["Zusatz"] = "ABCDEFG";

//dic["$ASPECTS"] = true;

//dic["TYPE"] = "tYpE";

//dic["$INDRESULTS"] = false;

//dic["BVB2"] = false;

//dic["BVB1"] = "";

//dic["$MINDPR"] = true;

//dic["DATVORG"] = DateTime.Now.AddYears(1);

return dic; }

No matter how many fields will be used to do mail merge and what data types they are, the NULL Reference exception will always be thrown.

Currently we use Aspose.Words 13.2 and the result looks fine, but when using any version incluing new hyphenation functionality, for example, 14.9, null reference exception is always thrown. Could you have a look at it?

Thank you.

Test Template 1

Test Template 2

Test Template 3

The size of these three templates is very big (at least 1 MB). I'm not sure whether I've posted them successfully. If you need them,could you provide me a mail address and I'll post it to it.

Thanks.

Hi Sheng,


Thanks for your inquiry. I was successfully able to download three documents that you attached in this thread. However, please create a standalone runnable console application (source code) that helps us reproduce your problem on our end and attach it here for testing. Also, please attach related hyphenation dictionary files. As soon as you get this simple application ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

Best regards,

Hi Awais,

Thank you for your reply. First here I attached a zip file including source file, although it is the same as what I had attached as code text in post above. Second, I'm afraid you misunderstood my point. What I said is the purpose of our Aspose.Words upgrade this time is to use your latest auto-hyphenation feature in PDF, but before taking advantage of it, we have to use Aspose.Words to generate a Word document with merge field first. And I found that merge field updating enctounered exception with your latest version Aspose.Words. It stops our system. So it's very serious. So the purpose of this post is to request you to investigate this merge field updating exception, NOT pdf hyphenation part. I hope you can understand it now. The given source code and attached templates could show you the exception.

Thanks.

Hi Sheng,


Thanks for your inquiry. I tested the scenario and have managed to reproduce the same problem on my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-10937. We will further look into the details of this problem and keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

The issues you have found earlier (filed as WORDSNET-10937) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.