NullReferenceException Is Thrown When Converting PPT to HTML5 in C#

I’ve attached a PowerPoint file we ran into that causes the following error when attempting to use the HTML5 save format.

I stripped the deck down to the one slide and element that causes the issue.

System.NullReferenceException: Object reference not set to an instance of an object.
at .(IShape )
at .[T](T , TemplateContext1 ) at .e() at .[T](String , TemplateContext1 , TextWriter )
at .[T](TextWriter , String , TemplateContext1 ) at e.(IShape , Slide , Boolean , Int32 , Dictionary2 , Boolean , Boolean )
at e.e()
at .[T](String , TemplateContext1 , TextWriter ) at .[T](TextWriter , String , TemplateContext1 )
at e.e()
at e.Compile(String , Object )
at e.Write(Stream )
at .Save(String , IOutputFile )
at Aspose.Slides.Export.Web.WebDocument.Save()
at .(Presentation , Stream , Int32[] , IHtml5Options )
at .(Presentation , Stream , Int32[] , Html5Options , InterruptionToken )
at .(Presentation , Stream , Html5Options , InterruptionToken )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at Aspose.Slides.Presentation.Save(String fname, SaveFormat format)

Nothing special in the code, effectively it’s just:

var destination = new Presentation(sourcePath);
var destinationPath = Path.GetTempFileName();
destination.Save(destinationPath, SaveFormat.Html5);

crash.ppt.zip (458.7 KB)

@tomibigpi

It looks like you’re encountering a System.NullReferenceException when trying to save a PowerPoint presentation in HTML5 format, while it works fine with the standard HTML format. This issue can arise due to specific elements in the presentation that are not fully supported or have issues when exporting to HTML5.

Cause: The error may be triggered by unsupported elements such as certain shapes, animations, or embedded objects in your presentation.

Solution: Here are some steps to diagnose and potentially resolve the issue:

  1. Check for Unsupported Elements: Review the slide and elements in your presentation. Try removing or simplifying elements that may not be compatible with HTML5 export to see if the error persists.

  2. Update to the Latest Version: Ensure you are using the latest version of the Aspose.Slides library, as bugs are often fixed in newer releases.

  3. Use Try-Catch for Debugging: Wrap your save operation in a try-catch block to capture more detailed error information. This can help identify which specific element is causing the issue.

    try
    {
        var destination = new Presentation(sourcePath);
        var destinationPath = Path.GetTempFileName();
        destination.Save(destinationPath, SaveFormat.Html5);
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Error: {ex.Message}");
    }
    
  4. Test with a Simplified Presentation: If you have already stripped down the deck, ensure that the remaining elements are as simple as possible. If the issue persists, consider testing with a completely new presentation to isolate the problem.

  5. Contact Support: If none of the above steps resolve the issue, reach out to Aspose support with the specific presentation file that causes the error for more targeted assistance.

Next Steps: Please try the suggested steps and let me know if they help resolve the issue. If you continue to experience problems, provide any additional details or error messages you encounter, and I will assist you further. Thank you!

Need a human from support to review.

@tomibigpi,
Thank you for contacting free support. I need some time to investigate the issue. I will get back to you as soon as possible.

@tomibigpi,
Thank you for your patience. I have reproduced the NullReferenceException when converting the PowerPoint presentation to a HTML5 document. 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-45094

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.

The issues you found earlier (filed as SLIDESNET-45094) have been resolved in Aspose.Slides for .NET 25.9 (ZIP, MSI, NuGet, Cross-platform).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.

1 Like