aspose.Words v14.5 - Aspose.Words.Document Constructor StackOverflow

I have been trying to instantiate a Aspose.Words.Document with several different .docx and I’m getting stack overflow exceptions. I have attached an example file and below is the code snip…

case "doc":
case "docx":
case "dot":
case "dotx":
case "html":
case "mhtml":
case "rtf":
    Aspose.Words.LoadOptions wordOpt = new Aspose.Words.LoadOptions();
    wordOpt.LoadFormat = Aspose.Words.LoadFormat.Auto;
    wordOpt.PreserveIncludePictureField = true;
    if (switchVar == "doc") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Doc;
    if (switchVar == "docx") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Docx;
    if (switchVar == "rtf") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Rtf;
    if (switchVar == "dot") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Dot;
    if (switchVar == "dotx") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Dotx;
    if (switchVar == "html") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Html;
    if (switchVar == "mhtml") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Mhtml;
    try
    {
        Aspose.Words.Document wordDoc = new Aspose.Words.Document(input.FullName, wordOpt);
        wordDoc.Save(output.FullName, Aspose.Words.SaveFormat.Pdf);
    }
    catch
    {
        throw;
    }
    break;

Hi Cary,

Thanks for your inquiry. After an initial test with Aspose.Words for .NET 14.10.0, I was unable to reproduce this issue on my side. I would suggest you please upgrade to the latest version of Aspose.Words. You can download it from the following link. I hope, this helps.

https://downloads.aspose.com/words/net

Best regards,

I have tried Aspose.Words v14.5-v14.10 (.Net 2.0 and .Net 3.5 builds.) and I have the same result… I have attached a new example file.

An unhandled exception of type ‘System.StackOverflowException’ occurred in Aspose.Words.dll

---------------------------Environment---------------------

Microsoft Visual Studio 2010
Version 10.0.30319.1 RTMRel
Microsoft .NET Framework
Version 4.0.30319 RTMRel
Installed Version: Professional
Microsoft Visual C# 2010 01018-532-2002102-70030
Microsoft Visual C# 2010

#region Word
case "doc":
case "docx":
case "dot":
case "dotx":
case "html":
case "mhtml":
case "rtf":
    Aspose.Words.LoadOptions wordOpt = new Aspose.Words.LoadOptions();
    wordOpt.LoadFormat = Aspose.Words.LoadFormat.Auto;
    // wordOpt.PreserveIncludePictureField = true;
    if (switchVar == "doc") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Doc;
    if (switchVar == "docx") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Docx;
    if (switchVar == "rtf") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Rtf;
    if (switchVar == "dot") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Dot;
    if (switchVar == "dotx") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Dotx;
    if (switchVar == "html") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Html;
    if (switchVar == "mhtml") wordOpt.LoadFormat = Aspose.Words.LoadFormat.Mhtml;
    try
    {
        GC.Collect();
        GC.WaitForPendingFinalizers();
        Aspose.Words.Document wordDoc = new Aspose.Words.Document(input.FullName, wordOpt);
        wordDoc.Save(output.FullName, Aspose.Words.SaveFormat.Pdf);
    }
    catch
    {
        throw;
    }
    break;
case "txt":
    string tmpTxtFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".pdf");
    TextReader trTxt = new StreamReader(input.FullName);
    Pdf pdfTxt = new Pdf();
    Aspose.Pdf.Generator.Section secTxt = pdfTxt.Sections.Add();
    Aspose.Pdf.Generator.Text tTxt = new Aspose.Pdf.Generator.Text(trTxt.ReadToEnd());
    trTxt.Close();
    secTxt.Paragraphs.Add(tTxt);
    pdfTxt.IsLandscape = isLandscape;
    pdfTxt.Save(output.FullName);
    break;
#endregion

Hi Cary,

Thanks for your inquiry. I am afraid, I was still unable to reproduce this issue on my side. Please try upgrading to the latest version 14.11.0 from the following link:

https://downloads.aspose.com/words/net

In case the problem still remains, please create a standalone runnable console application that helps us reproduce your problem on our end and attach it here for testing. As soon as you get this simple application ready, we’ll start further investigation into your issue and provide you more information. Thanks for your cooperation.

Best regards,