Aspose Words for .net error after upgrade

Hi,

I have upgraded to version 11 to support .NET 4.0 (previously using .NET 1.1).
Now seeing this error. Can you tell me what I can do to mitigate the issue.

The best overloaded method match for Aspose.Word.Document.Document(System.IO.Stream, Aspose.Words.LoadOptions) has some invalid argument.

for the following code block.

public static MemoryStream ExecuteMerge(MemoryStream wordDocument, DataTable mergeData)
{
    Aspose.Words.Document doc = new Aspose.Words.Document(wordDocument, LoadFormat.Doc);
    wordDocument.Close();
    doc.MailMerge.Execute(mergeData);

    SharedData companyInfoShared = new SharedData();
    doc.MailMerge.Execute(companyInfoShared.GetFormatKeys(), companyInfoShared.GetReplacedFormatValues());

    MemoryStream stream = new MemoryStream();
    doc.Save(stream, Aspose.Words.SaveFormat.Doc);
    return stream;
}

And seeing the following error for the code below

Æ Aspose.Words.DocumentÆ does not contain a constructor that takes 4 argument

public static MemoryStream ExecuteMerge(MemoryStream wordDocument, string[] parmName, object[] parmValue)
{
    Aspose.Words.Document doc = new Aspose.Words.Document(wordDocument, null, LoadFormat.Doc, null);
    wordDocument.Close();
    doc.MailMerge.Execute(parmName, parmValue);

    SharedData companyInfoShared = new SharedData();
    doc.MailMerge.Execute(companyInfoShared.GetFormatKeys(), companyInfoShared.GetReplacedFormatValues());

    MemoryStream stream = new MemoryStream();
    doc.Save(stream, Aspose.Words.SaveFormat.Doc);
    return stream;
}

Thanks

Hi,

Thanks for your inquiry. In your shared code, you are using Document’s constructor incorrectly. Please check the details about Document’s constructor from following documentation link.
https://reference.aspose.com/words/net/aspose.words/document/document/

I have modified your code, please check the highlighted section. Please use latest version of Aspose.Words for .NET 11.9.0.

public static MemoryStream ExecuteMerge(MemoryStream wordDocument, DataTable mergeData)
{
    LoadOptions loadOptions = new LoadOptions();
    loadOptions.LoadFormat = LoadFormat.Doc;
    Aspose.Words.Document doc = new Aspose.Words.Document(wordDocument, loadOptions);
    wordDocument.Close();
    doc.MailMerge.Execute(mergeData);
    SharedData companyInfoShared = new SharedData();
    doc.MailMerge.Execute(companyInfoShared.GetFormatKeys(), companyInfoShared.GetReplacedFormatValues());
    MemoryStream stream = new MemoryStream();
    doc.Save(stream, Aspose.Words.SaveFormat.Doc);
    return stream;
}

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Thanks Tahir
I have incorporated your suggestion.
However, I am unable to test it because I am getting the following error.
Inner exception: Could not load file or assembly ‘Aspose.Words, Version=11.6.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. The system cannot find the file specified.
Inner exception: Could not load file or assembly ‘Aspose.Words, Version=11.6.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. The system cannot find the file specified.

Hi,

Thanks for your inquiry. Please note that Aspose.Words dll Net 2.0 assembly is used for 2.0, 3.0, 3.5 and 4.0 .net frameworks. So kindly use net 2.0 assembly of Aspose.Words with 4.0 .net framework. Hopefully it will serve your purpose.

Currently, Aspose.Words does not offer DLL specifically written for .Net Framework 4.0. You can also try using the assembly from the ‘net3.5_ClientProfile’ folder as it contains assemblies to use with .NET Framework 3.5 or 4.0 Client Profile. I suggest you, please use latest version of Aspose.Words for .NET 11.9.0.

Please let me know if I can be of any further assistance.