Free Support Forum - aspose.com

Exception: NullReferenceException on saving PPTM to PPT

Hi,

From time to time I get error during saving presentation as PPT. Issue happens randomly.

The strange thing is that when I replicate the issue (I use Debugger.Launch when Save throws exception) and execute Save method once more, it works w/o exception.

My app is multi-threaded. Does Aspose.Slides use any static resources?

at Aspose.Slides.GradientFormat.(IGradientFormat )
at Aspose.Slides.   .(ILineFillFormat )
at Aspose.Slides.LineFillFormat.(ILineFillFormat )
at Aspose.Slides.   .(ILineFormat )
at Aspose.Slides.LineFormat.(ILineFormat )
at Aspose.Slides.   .rtjjzfbbfg6eqgb66mvby7b3ksz6huuh  (IBasePortionFormat )
at Aspose.Slides.   .rtjjzfbbfg6eqgb66mvby7b3ksz6huuh  (IBasePortionFormat )
at Aspose.Slides.BasePortionFormat.(IBasePortionFormat )
at Aspose.Slides.   .(IShape ,     )
at Aspose.Slides.   .(​   )
at Aspose.Slides.​  .c66sdxeglzcfjxnsn7sz9npahp4yvacy  ()
at Aspose.Slides.   .(    )
at Aspose.Slides.   .(    )
at Aspose.Slides.   .(    )
at Aspose.Slides.   .(    )
at Aspose.Slides.   . ()
at Aspose.Slides.   .()
at Aspose.Slides.   .(Stream , ISaveOptions )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format,
                                        ISaveOptions options)
at Aspose.Slides.Presentation.Save(String fname, SaveFormat format)

Thanks.

@licenses,

I have observed the issue shared by you and request you to please try using latest Aspose.Slides for .NET 19.10. In case the issue is still occurring then please share the source file reproducing the issue on your end along with working sample project.

Hi

  • We are already using 19.10.
  • Attached sample file sample.zip. Though I am not sure that it will help. As I said, issue happens randomly when multiple files are processed simultaneously. And there is other code in the app, not related to file processing. The same code executed after the exception on exactly same file does not produce exception. That is why I asked whether Aspose.Slides uses some static or system resources.
  • Cannot provide sample project because issue is replicated only in production code.

Code that produced error

using (var pres = new Presentation("file path", new LoadOptions())) {
    pres.Save(@"...", SaveFormat.Ppt);
}

@licenses,

I have worked with source file shared by you using Aspose.Slides for .NET 19.10 and unable to observe the issue. I have also shared my generated result with you for your kind reference.resultssample.zip (22.1 KB)

I’m having the same issue. Automation works fine on 19.09, but throws an exception when storing as PPTX on 19.10. This isn’t random for me, it happens on every save attempt.

System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Aspose.Slides
StackTrace:
at Aspose.Slides.Cell.get_Slide()
at Aspose.Slides.TextFrame.get_Slide()
at Aspose.Slides.ParagraphCollection.()
at Aspose.Slides.ParagraphCollection.b2c5x3anyvyabfwfht9wmzb4qm76xsa6 ()
at Aspose.Slides.Paragraph.yd3j8cvl2vtymz2ekh5aza9rjj8aet83 ()
at Aspose.Slides.Portion.p7dwjvrguh8avg4ybevrkrm7p8z8mukk ()
at ​ .()
at ​ .( )
at ​ .()
at ​ .get_Color()
at Aspose.Slides.ColorFormat.get_Color()
at ​ . (IColorFormat )
at .GetHashCode( )
at . (IFillFormat )
at .GetHashCode( )
at . (IPortionFormat )
at .GetHashCode( )
at System.Collections.Generic.Dictionary`2.Remove(TKey key)
at ​ .( )
at ​ . ( , )
at Aspose.Slides.Paragraph.get_EndParagraphPortionFormat()
at .(IParagraphCollection , , ​ )
at .(ITextFrame , , ​ )
at .(ITextFrame , , ​ )
at .(ICell , , ​ )
at .(Table , , ​ )
at ​ .(IGroupShape , , ​​ , )
at .(IBaseSlide , , ​​ )
at ​ .(ISlide )
at ​​ .( , ISlide , ​ )
at ​​ .(IPresentation , Stream , PresentationTypeEx , IPptxOptions , InterruptionToken )
at Aspose.Slides.Presentation.(Stream , PresentationTypeEx , IPptxOptions )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at Aspose.Slides.Presentation.Save(String fname, SaveFormat format)

@bhickman,

Can you please share source code along with sample file so that we may further investigate to help you out.

I’ve attached a PPTX template and listed a code snippet that causes the exception.
foo.zip (22.7 KB)

Notes:

  • The contents of the table are somehow involved. If I change what is inserted in the table, the exception may go away.
  • The PDF is saved without error, but the table is not rendered in the PDF.
  • Both PDF and PPTX save without issues using 19.9
  • This is a .NET Core 3 application
  • The row clones don’t work perfectly. Observe that the second clone of templateRow1 doesn’t properly apply BOLD to the text in cell 0.
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Loading presentation template...");
                using (var presentation = new Presentation("foo.pptx"))
                {
                    // Find the table
                    var table = (ITable)presentation.Slides.First().Shapes.First(s => s is ITable);

                    // Use the two table rows as templates
                    var templateRow1 = table.Rows[0];
                    var templateRow2 = table.Rows[1];

                    // Inject some new rows based on the template rows
                    var newRow = table.Rows.AddClone(templateRow1, false).First();
                    newRow[0].TextFrame.Text = "Bucket 1";

                    newRow = table.Rows.AddClone(templateRow2, false).First();
                    newRow[0].TextFrame.Text = "Global *";
                    newRow[1].TextFrame.Text = "Finest Capital Corp";
                    newRow[2].TextFrame.Text = "Bestest Capital Ltd";
                    newRow[3].TextFrame.Text = "Mostly Inv LLC";
                    newRow[4].TextFrame.Text = "Sandstone Capital, LLC";
                    newRow[5].TextFrame.Text = "Worchest Mgmt Intl Ltd";

                    newRow = table.Rows.AddClone(templateRow2, false).First();
                    newRow[0].TextFrame.Text = "Emering Equities *";
                    newRow[1].TextFrame.Text = "Noonian Inv LLC";
                    newRow[2].TextFrame.Text = "Sunset Capital Mgmt LLP";
                    newRow[3].TextFrame.Text = "Hardly Trying LP";
                    newRow[4].TextFrame.Text = "Walntu Capital Mgmt, LP";
                    newRow[5].TextFrame.Text = "Eastwood Mgmt Corp.";

                    newRow = table.Rows.AddClone(templateRow2, false).First();
                    newRow[0].TextFrame.Text = "European *";
                    newRow[1].TextFrame.Text = "Mostly Inv LLC";

                    newRow = table.Rows.AddClone(templateRow2, false).First();
                    newRow[0].TextFrame.Text = "Japan *";
                    newRow[1].TextFrame.Text = "Asset Management Two Co Ltd";
                    newRow[2].TextFrame.Text = "Coopers Cards";

                    newRow = table.Rows.AddClone(templateRow2, false).First();
                    newRow[0].TextFrame.Text = "Pacific ex Japan *";
                    newRow[1].TextFrame.Text = "BlackHat South Asia";
                    newRow[2].TextFrame.Text = "Mostly Inv LLC";

                    // Inject some new rows based on the template rows
                    newRow = table.Rows.AddClone(templateRow1, false).First();
                    newRow[0].TextFrame.Text = "Bucket 2";

                    newRow = table.Rows.AddClone(templateRow2, false).First();
                    newRow[0].TextFrame.Text = "Investment Grade";
                    newRow[1].TextFrame.Text = "Crisis Management Investment Advisers, LLC";
                    newRow[2].TextFrame.Text = "A. Good Price International Ltd";
                    newRow[3].TextFrame.Text = "BottleBay Asset Mgmt LLP";
                    newRow[4].TextFrame.Text = "Kripke Capital Mgmt N.V.";
                    newRow[5].TextFrame.Text = "ROBERT INSTITUTIONAL STUFF MANAGEMENT C.V.";

                    newRow = table.Rows.AddClone(templateRow2, false).First();
                    newRow[0].TextFrame.Text = "High Yield *";
                    newRow[1].TextFrame.Text = "RAH Capital Mgmt, LLC";
                    newRow[2].TextFrame.Text = "Barllye LLC";
                    newRow[3].TextFrame.Text = "Hardhome Inv Mgmt Ltd";

                    newRow = table.Rows.AddClone(templateRow2, false).First();
                    newRow[0].TextFrame.Text = "Emerging Markets Debt";
                    newRow[1].TextFrame.Text = "Barley LLC";
                    newRow[2].TextFrame.Text = "RAH LLC";
                    newRow[3].TextFrame.Text = "Coolkids Global Investors Limited";

                    newRow = table.Rows.AddClone(templateRow2, false).First();
                    newRow[0].TextFrame.Text = "Convertible Bonds";
                    newRow[1].TextFrame.Text = "BottleBay Asset Management LLP";

                    newRow = table.Rows.AddClone(templateRow2, false).First();
                    newRow[0].TextFrame.Text = "Alternative Credit *";
                    newRow[1].TextFrame.Text = "Putters Advisory Co, LLC";
                    newRow[2].TextFrame.Text = "MnM Asset Management LLP";
                    newRow[3].TextFrame.Text = "Haredly Inv Mgmt Ltd";
                    newRow[4].TextFrame.Text = "Kres Advisory Group, LLC";

                    // Remove the template rows
                    table.Rows.RemoveAt(0, false);
                    table.Rows.RemoveAt(0, false);

                    // Save pdf
                    Console.WriteLine("Saving as PDF...");
                    presentation.Save("bar.pdf", SaveFormat.Pdf);

                    // Save pptx
                    Console.WriteLine("Saving as PPTX...");
                    presentation.Save("bar.pptx", SaveFormat.Pptx);

                    Console.WriteLine("ALL DONE");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("EXCEPTION:" + ex.Message);
                Console.WriteLine(ex);
            }
        }
    }

@bhickman,

I have worked with the sample project shared by you using Aspose.Slides for .NET 19.10 and Visual Studio with .NET Core. I have been able to reproduce the issue. An issue with ID SLIDESNET-41564 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be addressed.

I have worked with source file shared by you using Aspose.Slides for .NET 19.10 and unable to observe the issue. I have also shared my generated result with you for your kind reference.resultssample.zip (22.1 KB)

I am not surprised. As I said earlier, issue can be randomly replicated and only on production environment.

Can you please share stack trace and all the details, which I provided in the initial and later posts, with developers. They will be able to analyze code and check what may cause NullReferenceException in GradientFormat.xxxx. Maybe some static or system resource is used there.

Thanks.

@licenses,

Can you please share complete environment details with us so that we may further investigate to help you out.

Hard to tell what exactly you may need.

  • Windows 10
  • .NET Framework 4.7
  • Application is multi-threaded Windows Service
  • Application uses the following Aspose products: Cells, Words, Slides, Email, PDF.

@licenses,

I have observed your comments. A ticket as investigation with ID SLIDESNET-41569 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been associated with the ticket so that we may share the notification with you once issue will be fixed.

@licenses,

We have investigated the issue on our end and have observed that the stack trace is obfuscated. Can you please share more info about the issue’s reproducing details? If there’s a multi-threaded environment. Can you please share the sample project that is demonstrating multiple threads working with presentations, etc. - how this issue can be reproduced and we may test. Please share the requested information so that we may proceed further with investigation on our end.

The issues you have found earlier (filed as SLIDESNET-41564) have been fixed in this update.