System.NullReferenceException exception in Presentation constructor and elsewhere


#1

I am evaluating Aspose Powerpoint using version 2.1.2.0 using a very small test class - I have included the code at the bottom of this message. I get a very large number of exceptions raised and apparent caught in the Aspose code. Is this normal, or can I do something about? I feel as if there must something very simple that I have missed!

Here are the details:

I have taken a copy of the supplied file "demo.ppt" and renamed it "TemplateForAspose.ppt" for purpose of this test.

On the following line (full code is below):
Presentation theGen = new Aspose.PowerPoint.Presentation(thePath);
a System.NullReferenceException is raised with the message "Object reference not set to an instance of an object".

The stack trace shows:
Aspose.PowerPoint.MainMaster::.ctor()
Aspose.PowerPoint.Presentation::.ctor()
Aspose.PowerPoint.Presentation::.ctor()
Aspose.PowerPoint.Presentation::.ctor()
PowerPointCSharpTest.SimpleTestX::Execute()

A further 43 identical exceptions are then raised before the constructor exits.

Then on the line:
Aspose.PowerPoint.Slide theSlide = theGen.AddBodySlide();
we get a System.IO.FileNotFoundException with message "No such entry: 'Pictures'". This is followed by about another 40 NullReferenceExceptions apparently identical to the ones described above.

However, the code seems to work: the new slide is added and the trivial change I have coded for does actually take place and can be viewed in the saved file.

__________________________________________________________

public class SimpleTestX
{
public SimpleTestX()
{
//
// TODO: Add constructor logic here
//
}


public void Execute(){
string thePath = HttpContext.Current.Server.MapPath(@"~\TemplateForAspose.ppt");
Presentation theGen = new Aspose.PowerPoint.Presentation(thePath);
string x = "";

Aspose.PowerPoint.Slide theSlide = theGen.AddBodySlide();
for(int i = 0; i < theSlide.Placeholders.Count; i++){
string s = theSlide.PlaceholdersIdea.PlaceholderType.ToString();
x = x + s;
if (theSlide.PlaceholdersIdea.PlaceholderType == PlaceholderType.Body){
TextHolder th = theSlide.PlaceholdersIdea as TextHolder;
th.Paragraphs[0].Portions[0].Text = "This is the replaced text in the body.";
}
}

thePath = HttpContext.Current.Server.MapPath(@"~\ModifiedByAspose.ppt");
theGen.Write(thePath);
}
}

__________________________________________________________

Many thanks for your attention,

Richard Cox.


#2

Dear Richard,

All these exceptions are internal. They are catched by Aspose.PowerPoint and shouldn’t be visible outside library by default. So check setting of your VS, debugger or anything else.


#3

Thank you Alexey, I wondered if that might be the case.

I am using Delphi 2005, and I cannot find a way to avoid seeing your exceptions without turning off IDE notification of all System.NullReferenceExceptions.

Many thanks for the fast response.

Richard Cox.