System.NullReferenceException when trying to view a PST file as PDF

I am currently trying to view a .PST file using GroupDocs.Viewer 23.1.0 in an ASP.NET MVC application using .NET Framework 4.8, when I try to view a PST file with PDF settings I get the following error: “System.NullReferenceException: ‘Object reference not set to an instance of an object.’”

Full Error Message: System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=GroupDocs.Viewer
StackTrace:
at  .(MessageInfo )

Code for Viewing File:

GroupDocs.Viewer.Caching.FileCache cache = new GroupDocs.Viewer.Caching.FileCache(cachePath);
            ViewerSettings settings = new ViewerSettings(cache);

            using (GroupDocs.Viewer.Viewer viewer = new GroupDocs.Viewer.Viewer(selectedVersion.fileheaderversionStrFilePath, settings))
            {
                ViewOptions viewOptions = new PdfViewOptions(outputPath);

                viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet();
                //viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForSplitSheetIntoPages(100);
                viewOptions.SpreadsheetOptions.SkipEmptyRows = false;
                viewOptions.SpreadsheetOptions.SkipEmptyColumns = false;
                viewOptions.SpreadsheetOptions.RenderGridLines = true;
                viewOptions.SpreadsheetOptions.RenderHeadings = true;

                viewOptions.RenderHiddenPages = true;
                if(userRec == null)
                {
                    viewOptions.Watermark = new Watermark("Test");
                }
                else
                {
                    viewOptions.Watermark = new Watermark("Test");
                }
                viewOptions.Watermark.Color = System.Drawing.Color.FromArgb(50, 0, 66, 113);

                viewOptions.CadOptions.RenderLayouts = true;

                viewer.View(viewOptions);
            }

@rhuebnerNNI

Can you please attach the PST file for the further investigation?

sample.zip (10.8 KB)

I have attached the document, I had to zip the file as I was not allowed to upload a .PST file.

@rhuebnerNNI

Unfortunately, I have failed to reproduce this issue locally with the following sample-app.zip (12.3 KB)
and the file you’ve attached. Can you please update the app or provide you app, so we could reproduce the issue?

I ran your sample-app and got the error that I am experiencing.
image.png (15.2 KB)

@rhuebnerNNI

Please share which OS you’re using. In addition please try running the following code and share the output

ViewerSettings settings = new ViewerSettings(
    new ConsoleLogger());

using (Viewer viewer = new Viewer("./sample.pst", settings))
{
    ViewOptions viewOptions = new PdfViewOptions("output.pdf");

    viewer.View(viewOptions);
}

Operating System Information:
OS Name Microsoft Windows 11 Pro
Version 10.0.22621 Build 22621

Output: image.png (74.0 KB)

@rhuebnerNNI

Thank you for sharing the details. At the moment I can’t reproduce the same issue. Please also share a stack trace and console output.

I have attached the requested files as a zip.ViewerSampleApp.zip (355.7 KB)

@rhuebnerNNI

Thank you for attaching the dump. I can see where the issue is located but still can’t reproduce it locally. We’ll try different environments and update you.

Thank you, please let me know if you need any additional information.

@rhuebnerNNI

At the moment I have tried to reproduce this issue in two different environments on Windows 10 and 11 but have failed to get the same exception.

I am unsure if it would matter, but I am using Visual Studio 2022 Professional.

@rhuebnerNNI

Do you run Visual Studio as Administrator?

I ran my Visual Studio as Administrator, but still am getting the same error.

@rhuebnerNNI

Got it, thanks will try reproducing it. It may be some issue related to the environment configuration. Can you also try to reproduce it on another machine?

I will try to reproduce it on a couple different machines and operating systems.

Tested Devices and Operating Systems:

Device: 2021 MacBook Pro 16-inch (Apple M1 Pro)
OS: macOS Monterey 12.6
IDE: Visual Studio for Mac
Error: GroupDocs.Viewer.Exceptions.GroupDocsViewerException: The type initializer for ’ ’ threw an exception.

Device: Virtual Server
OS: Windows Server 2012 R2
IDE: Visual Studio 2022 Professional
Error: No Error

Device: Virtual Server
OS: Windows Server 2022
IDE: Visual Studio 2022 Community
Error: No Error


Are there any programs/addons that interfere with GroupDocs.Viewer that I can look for on my devices?

@rhuebnerNNI

Thank you for sharing the details. I’ll try reproducing the issue in macOS Monterey 12.6 and update you.

We’ll take a look at what may lead to such exception.

@rhuebnerNNI

I have introduced a potential fix to the Null reference exception. Can you please try this package NuGet QA Gallery | GroupDocs.Viewer 23.3.0-alpha-20230404005553 on your localhost?

Package source is https://apiint.nugettest.org/v3/index.json - see package-source.jpg (203.6 KB)