Exception when creating a Chart

I'm trying to create a basic chart in a PowerPoint slide in .Net Core and failing. I've modified the web sample and created a simple console app to test this out but get the following exception when trying to save the file. 

   {System.NullReferenceException: Object reference not set to an instance of an object.
   at Syncfusion.Presentation.FileDataHolder.Close()
   at Syncfusion.Presentation.Presentation.ClearAll()
   at Syncfusion.Presentation.Presentation.Close()
   at SyncTest.Program.CreatePPT(String filename) in C:\Dev\PresentationTest\SyncTest\Program.cs:line 34
   at SyncTest.Program.Main(String[] args) in C:\Dev\PresentationTest\SyncTest\Program.cs:line 16}

If I ignore the error and continue I get an error from PowerPoint when trying to open the file. The file is invalid and needs to be Repaired. 

Is there a simple example of creating a chart slide in .net core?

Attachment: SyncTest_e4ba899b.zip

3 Replies

KK Kumaravel Kulandai Samy Syncfusion Team December 13, 2017 11:17 AM UTC

Hi Brad,

Thank you for contacting Syncfusion support.

A support incident to track the status of your query has been created under your account. Please log on to our support website to check for further updates,

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let us know if you need further clarifications regarding this,

Regards,
 
Kumaravel 



BP Brad Patton December 13, 2017 04:04 PM UTC

I reported a separate issue with creating an empty presentation: https://www.syncfusion.com/forums/135026/creating-an-empty-presentation-throws-an-exception

I applied the patch given to me for that issue: https://www.syncfusion.com/support/directtrac/incidents/194592

Saving the presentation directly to file seemed to not be an option. So I changed my code to save to a stream and now it looks like the chart is now being created. I will do some more testing. But you may want to look at the direct file save code.

//Saves the presentation to the memory stream.
presentation.Save(ms);
//Set the position of the stream to beginning.
ms.Position = 0;

FileStream file = new FileStream(filename, FileMode.Create, FileAccess.Write);
ms.WriteTo(file);
file.Close();
ms.Close();


KK Kumaravel Kulandai Samy Syncfusion Team December 14, 2017 12:44 PM UTC

Hi  Brad, 
Yes, your code snippet will save the presentation in a stream. Also, we have  created a simple sample for the same and attached in below link. 
Please find the sample from the below link: 
Generated document: 
Please let us know if you need any further assistance in this. 
Regards, 
Kumaravel.K 


Loader.
Up arrow icon