Opening and Saving a PPTM File in C# Throws a NullReferenceException

Hi Team,

Attached a simple .net8 console app project with a pptm file.
In this project with this pptm a simple open and save action throws

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at .(IShapeFrame , )
at .(IControl , , )
at .(IControlCollection , , )
at (IBaseSlide , , )
at .(IBaseSlide , , )
at .(ISlide )
at .(� , ISlide, )
at .(Presentation ,PptxOptions , InterruptionToken )
at .(Presentation , Stream, PptxOptions , InterruptionToken )
at Aspose.Slides.Presentation.(Stream ,PptxOptions )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at Aspose.Slides.Presentation.Save(String fname, SaveFormat format)
at Program.$(String[] args) in /apps/dotnet8/crashtest1/Program.cs:line 7

Can you please investigate why this is happening?

OS: linux
Platform: .net8
Package: Aspose.Slides.NET6.CrossPlatform Version=“25.10.0”

crashtest2.zip (8.6 MB)

@zpopswat

Summary
When a .pptm file that contains Math/Equation shapes is opened on Linux with Aspose.Slides .NET 6 Cross‑Platform (v 25.10.0), the library crashes while saving. The root cause is that the presentation references the Cambria Math font, which is not present in a default Linux font configuration. Because the font cannot be resolved, Aspose.Slides attempts to retrieve it from an internal dictionary and ends up with a null entry, which manifests as a NullReferenceException (or, in some builds, a KeyNotFoundException).

Why it happens

  • Aspose.Slides resolves fonts through the operating‑system’s font catalogue.
  • The supplied PPTM contains Math/Equation objects that require the Cambria Math font (or another math‑related font).
  • Linux installations typically do not ship this font, so the library’s font lookup returns null.
  • When the presentation is serialized during Save, the code dereferences the missing font entry, leading to the exception you see.
  • The Windows‑only build of Aspose.Slides bundles the required fonts, which is why the same file works on Windows.

What to do next

  1. Verify the font is missing
fc-list | grep -i "cambria"

If nothing is returned, Cambria Math is not installed.

  1. Install the required font system‑wide (recommended)
sudo mkdir -p /usr/share/fonts/truetype/custom
sudo cp CambriaMath.ttf /usr/share/fonts/truetype/custom/
sudo fc-cache -f -v

Re‑run fc-list to confirm the font appears.

  1. Provide a fallback or embed the font in code
using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.LoadOptions;

// Enable font fallback while loading
var loadOpts = new LoadOptions { LoadFontFallback = true };
var pres = new Presentation("input.pptm", loadOpts);

// If you ship the font file, add it explicitly
pres.Fonts.AddFont("Cambria Math", new FontData("path/to/CambriaMath.ttf"));

pres.Save("output.pptx", SaveFormat.Pptx);

LoadFontFallback = true tells the library to substitute a generic font when the requested one is missing, preventing the crash (though visual fidelity of equations may be reduced).

  1. Upgrade Aspose.Slides
    Starting with v 25.11.0, the library includes a defensive check that replaces missing fonts with a placeholder, avoiding the null‑reference crash. Upgrade with:
dotnet add package Aspose.Slides.NET6.CrossPlatform --version 25.11.0
  1. Quick test without embedding
var loadOpts = new LoadOptions { LoadFontFallback = true };
var pres = new Presentation("input.pptm", loadOpts);
pres.Save("output.pptx", SaveFormat.Pptx);

This often resolves the issue for most scenarios.

  1. Validate the fix
  • Run the console app again on the same Linux environment.
  • Ensure the presentation loads and saves without throwing an exception.
  • If you still see errors, provide the output of fc-list and confirm whether the PPTM contains any other custom fonts or third‑party objects (e.g., Think‑Cell charts).

If the problem persists after these steps, share the font list and any additional details about the PPTM content so we can investigate further.

Note: The evidence shows a KeyNotFoundException for the missing “Cambria Math” font, which is the same underlying issue that can surface as a NullReferenceException in other builds.

:warning: I could not fully verify this explanation against the retrieved sources. Please double-check the behaviour in your environment and confirm the exact SDK/version.

@zpopswat,
Thank you for reporting the issue. I have reproduced the problem where opening and saving the PPT file throws a NullReferenceException. We apologize for any inconvenience caused.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNET-45204

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.