Free Support Forum - groupdocs.com

Excel File Throw a memory exception

I am testing out the evaluation version of the Viewer and would like to purchase however the code below throws a concerning memory exception. How soon will this be resolved?

    // Set viewer configuration
    ViewerConfig config = new ViewerConfig();
    config.StoragePath = @"C:\junk\";
    // Initailize ViewerHandler
    ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
    // Get Html pages
    List<PageHtml> pages = htmlHandler.GetPages(@"E:\Test.xlsx");

    MessageBox.Show("done");

And the error thrown is:

FatalExecutionEngineError occurred
  HResult=-2147467261
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  StackTrace:
       at    .        ()
       at    .        (String  , Stream  , RenderOptions  )
       at    .        ()
       at    . ()
       at    . ()
       at    .        ()
       at    . ()
  InnerException:

@Mike32,

Thanks for taking interest in GroupDocs.Viewer.

Please provide us the following so that we can investigate the issue at our end.

  • Version of GroupDocs.Viewer
  • Sample Excel document
  • A sample application (can be a simple console application without errors) that can be used to reproduce the issue at our end

We shall be looking forward to your response.

1 Like

Ok, today I just created a new project with the intention of sending it to you however it worked fine. I downloaded the latest NuGet package which was version 18.9.0. The project I was having an issue with was using version 18.8.1 so, I am assuming it was solved in the latest version. Thanks

For no other reason than me spending the time to write it, here is my code:

using GroupDocs.Viewer.Config;
using GroupDocs.Viewer.Domain.Html;
using GroupDocs.Viewer.Handler;
using System;
using System.Collections.Generic;

using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication5
{
    class Program
    {

        static void Main(string[] args)
        {
            Console.WriteLine("Converting to HTML...");

            // Set viewer configuration
            ViewerConfig config = new ViewerConfig();
            config.StoragePath = @"C:\junk\";

            // Initailize ViewerHandler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);

            // Get Html pages
            List<PageHtml> pages = htmlHandler.GetPages(@"C:\junk\test.xlsx");

            System.IO.File.WriteAllText(@"C:\junk\result.html", pages[0].HtmlContent);

            Console.WriteLine("Done");
            Console.ReadKey();

        }
    }
}

@Mike32,

It is good to know that your issue has been resolved with the latest version. One improvement in your provided code is, if you have set the StoragePath property of ViewerConfig then you don’t need to provide the complete file’s path in the GetPages method as shown in below code snippet.

ViewerConfig config = new ViewerConfig();
config.StoragePath = @"C:\junk\";
// Initailize ViewerHandler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
// Get Html pages
List<PageHtml> pages = htmlHandler.GetPages("test.xlsx");

In case you would have any other question or query, please do let us know.